New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

db-auto

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

db-auto - npm Package Compare versions

Comparing version 0.0.25 to 0.0.26

26

dist/src/cli.js

@@ -41,4 +41,9 @@ "use strict";

.argument('[id]', "the id of the primary key in the first table in the path")
.option('-p, --plan', "show the plan instead of executing", false)
.option(' --plan', "show the plan instead of executing", false)
.option('-s, --sql', "show the sql instead of executing", false)
.option('--fullSql', "normally the show sql doesn't include limits. This shows them", false)
.option('-c, --count', "returns the count of the items in the table", false)
.option('-d, --distinct', "only return distinct values", false)
.option('--page <page> ', "which page of the results should be returned")
.option("--pageSize <pageSize>", "Changes the page of the returned results", parseInt, 15)
.option('-t, --trace', "trace the results", false)

@@ -52,11 +57,18 @@ .option('-j, --json', "Sql output as json instead of columns", false)

.action((path, id, options) => __awaiter(this, void 0, void 0, function* () {
const where = options.where ? options.where : [];
let pathSpec = (0, tables_1.makePathSpec)(path, id, options, where);
const env = config.environments.dev;
if (options.trace) {
const pps = yield (0, path_1.tracePlan)(env, config.tables, pathSpec, options);
if (!env)
throw new Error('Need to have a dev environment');
const dialect = (0, environments_1.sqlDialect)(env.type);
const page = options.page ? parseInt(options.page) : 1;
const fullOptions = Object.assign(Object.assign({}, options), { limitBy: dialect.limitFn, page });
if (page < 1)
throw new Error("Page must be greater than 0");
const where = fullOptions.where ? fullOptions.where : [];
let pathSpec = (0, tables_1.makePathSpec)(path, id, fullOptions, where);
if (fullOptions.trace) {
const pps = yield (0, path_1.tracePlan)(env, config.tables, pathSpec, fullOptions);
pps.forEach(line => console.log(line));
return;
}
const errorsOrresult = yield (0, path_1.processPathString)(env, config.tables, pathSpec, options);
const errorsOrresult = yield (0, path_1.processPathString)(env, config.tables, pathSpec, fullOptions);
if ((0, utils_1.hasErrors)(errorsOrresult)) {

@@ -66,3 +78,3 @@ (0, utils_1.reportErrors)(errorsOrresult);

}
(0, path_1.prettyPrintPP)(options, errorsOrresult).forEach(line => console.log(line));
(0, path_1.prettyPrintPP)(fullOptions, errorsOrresult).forEach(line => console.log(line));
}));

@@ -69,0 +81,0 @@ (0, tables_1.findQueryParams)(config.tables).forEach(param => program.option('--' + param.name + " <" + param.name + ">", param.description));

import { ErrorsAnd, NameAnd } from "@db-auto/utils";
import { CleanTable, PathSpec, SelectData } from "@db-auto/tables";
import { CleanTable, PathSpec, SelectData, SqlOptions } from "@db-auto/tables";
import { Environment } from "@db-auto/environments";

@@ -22,5 +22,6 @@ import { DalResult, DalResultDisplayOptions } from "@db-auto/dal";

type PP = SelectDataPP | LinksPP | SqlPP | ResPP;
interface ProcessPathOptions extends DalResultDisplayOptions {
interface ProcessPathOptions extends DalResultDisplayOptions, SqlOptions {
plan?: boolean;
sql?: boolean;
fullSql?: boolean;
}

@@ -27,0 +28,0 @@ export declare function processPathString(env: Environment, tables: NameAnd<CleanTable>, pathSpec: PathSpec, options: ProcessPathOptions): Promise<ErrorsAnd<PP>>;

@@ -15,3 +15,3 @@ "use strict";

const tables_1 = require("@db-auto/tables");
const postgres_1 = require("@db-auto/postgres");
const environments_1 = require("@db-auto/environments");
const dal_1 = require("@db-auto/dal");

@@ -47,9 +47,10 @@ function findLinks(tables, path) {

const data = (0, tables_1.selectData)("all")(plan);
const { plan: showPlan, sql: showSql } = options;
const { plan: showPlan, sql: showSql, fullSql } = options;
if (showPlan)
return { type: 'selectData', data };
const sql = (0, tables_1.sqlFor)((0, tables_1.mergeSelectData)(data));
if (showSql)
const optionsModifiedForLimits = showSql && !fullSql ? Object.assign(Object.assign({}, options), { limitBy: undefined }) : options;
const sql = (0, tables_1.sqlFor)(optionsModifiedForLimits)((0, tables_1.mergeSelectData)(data));
if (showSql || fullSql)
return ({ type: 'sql', sql });
const dal = (0, postgres_1.postgresDal)(env);
const dal = (0, environments_1.dalFor)(env);
try {

@@ -56,0 +57,0 @@ const result = { type: 'res', res: yield dal.query(sql.join(' ')) };

@@ -112,3 +112,3 @@ "use strict";

const actual = yield (0, path_1.processPathString)(dev, tables_1.clean, pathSpec, { sql: true });
const sql = (0, utils_1.mapErrors)((0, tables_1.buildPlan)(tables_1.clean, pathSpec), plan => (0, tables_1.sqlFor)((0, tables_1.mergeSelectData)((0, tables_1.selectData)("all")(plan))));
const sql = (0, utils_1.mapErrors)((0, tables_1.buildPlan)(tables_1.clean, pathSpec), plan => (0, tables_1.sqlFor)({})((0, tables_1.mergeSelectData)((0, tables_1.selectData)("all")(plan))));
const expected = { type: 'sql', sql };

@@ -115,0 +115,0 @@ return { actual, expected };

{
"name": "db-auto",
"description": "",
"version": "0.0.25",
"version": "0.0.26",
"main": "dist/index",

@@ -24,10 +24,10 @@ "types": "dist/index",

"commander": "^10.0.0",
"@db-auto/oracle": "0.0.25",
"@db-auto/mysql": "0.0.25",
"@db-auto/postgres": "0.0.25",
"@db-auto/tables": "0.0.25",
"@db-auto/utils": "0.0.25",
"@db-auto/files": "0.0.25",
"@db-auto/mocks": "0.0.25",
"@db-auto/environments": "0.0.25"
"@db-auto/oracle": "0.0.26",
"@db-auto/mysql": "0.0.26",
"@db-auto/postgres": "0.0.26",
"@db-auto/tables": "0.0.26",
"@db-auto/utils": "0.0.26",
"@db-auto/files": "0.0.26",
"@db-auto/mocks": "0.0.26",
"@db-auto/environments": "0.0.26"
},

@@ -34,0 +34,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc