Socket
Socket
Sign inDemoInstall

knex-schema-inspector

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

knex-schema-inspector - npm Package Compare versions

Comparing version 1.5.11 to 1.5.12

dist/utils/strip-quotes.d.ts

3

dist/dialects/oracledb.js

@@ -40,2 +40,3 @@ "use strict";

exports.rawColumnToColumn = void 0;
var strip_quotes_1 = require("../utils/strip-quotes");
function rawColumnToColumn(rawColumn) {

@@ -46,3 +47,3 @@ return {

data_type: rawColumn.DATA_TYPE,
default_value: rawColumn.DATA_DEFAULT,
default_value: strip_quotes_1.stripQuotes(rawColumn.DATA_DEFAULT),
max_length: rawColumn.DATA_LENGTH,

@@ -49,0 +50,0 @@ numeric_precision: rawColumn.DATA_PRECISION,

@@ -43,2 +43,3 @@ "use strict";

exports.parseDefaultValue = exports.rawColumnToColumn = void 0;
var strip_quotes_1 = require("../utils/strip-quotes");
var lodash_isnil_1 = __importDefault(require("lodash.isnil"));

@@ -326,9 +327,6 @@ function rawColumnToColumn(rawColumn) {

return __awaiter(this, void 0, void 0, function () {
function stripQuotes(row) {
function stripRowQuotes(row) {
return Object.fromEntries(Object.entries(row).map(function (_a) {
var key = _a[0], value = _a[1];
if ((value === null || value === void 0 ? void 0 : value.startsWith('"')) && (value === null || value === void 0 ? void 0 : value.endsWith('"'))) {
return [key, value.slice(1, -1)];
}
return [key, value];
return [key, strip_quotes_1.stripQuotes(value)];
}));

@@ -342,3 +340,3 @@ }

result = _a.sent();
rowsWithoutQuotes = result.rows.map(stripQuotes);
rowsWithoutQuotes = result.rows.map(stripRowQuotes);
if (table) {

@@ -345,0 +343,0 @@ return [2 /*return*/, rowsWithoutQuotes.filter(function (row) { return row.table === table; })];

@@ -45,2 +45,3 @@ "use strict";

var extract_type_1 = __importDefault(require("../utils/extract-type"));
var strip_quotes_1 = require("../utils/strip-quotes");
var SQLite = /** @class */ (function () {

@@ -194,3 +195,3 @@ function SQLite(knex) {

data_type: extract_type_1.default(raw.type),
default_value: raw.dflt_value,
default_value: strip_quotes_1.stripQuotes(raw.dflt_value),
max_length: extract_max_length_1.default(raw.type),

@@ -197,0 +198,0 @@ /** @NOTE SQLite3 doesn't support precision/scale */

@@ -6,2 +6,3 @@ import { Knex } from 'knex';

import { ForeignKey } from '../types/foreign-key';
import { stripQuotes } from '../utils/strip-quotes';

@@ -30,3 +31,3 @@ type RawColumn = {

data_type: rawColumn.DATA_TYPE,
default_value: rawColumn.DATA_DEFAULT,
default_value: stripQuotes(rawColumn.DATA_DEFAULT),
max_length: rawColumn.DATA_LENGTH,

@@ -33,0 +34,0 @@ numeric_precision: rawColumn.DATA_PRECISION,

@@ -6,2 +6,3 @@ import { Knex } from 'knex';

import { ForeignKey } from '../types/foreign-key';
import { stripQuotes } from '../utils/strip-quotes';
import isNil from 'lodash.isnil';

@@ -450,3 +451,3 @@

const rowsWithoutQuotes = result.rows.map(stripQuotes);
const rowsWithoutQuotes = result.rows.map(stripRowQuotes);

@@ -459,10 +460,6 @@ if (table) {

function stripQuotes(row: ForeignKey): ForeignKey {
function stripRowQuotes(row: ForeignKey): ForeignKey {
return Object.fromEntries(
Object.entries(row).map(([key, value]) => {
if (value?.startsWith('"') && value?.endsWith('"')) {
return [key, value.slice(1, -1)];
}
return [key, value];
return [key, stripQuotes(value)];
})

@@ -469,0 +466,0 @@ ) as ForeignKey;

@@ -9,2 +9,3 @@ import { Knex } from 'knex';

import { ForeignKey } from '../types/foreign-key';
import { stripQuotes } from '../utils/strip-quotes';

@@ -157,3 +158,3 @@ type RawColumn = {

data_type: extractType(raw.type),
default_value: raw.dflt_value,
default_value: stripQuotes(raw.dflt_value),
max_length: extractMaxLength(raw.type),

@@ -160,0 +161,0 @@ /** @NOTE SQLite3 doesn't support precision/scale */

{
"name": "knex-schema-inspector",
"version": "1.5.11",
"version": "1.5.12",
"description": "Utility for extracting information about existing DB schema",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -89,2 +89,3 @@ import knex, { Knex } from 'knex';

{ table: 'users', column: 'password' },
{ table: 'users', column: 'status' },
{ table: 'users', column: 'team_id' },

@@ -290,2 +291,18 @@ { table: 'page_visits', column: 'created_at' },

{
name: 'status',
table: 'users',
data_type: 'varchar',
default_value: 'active',
max_length: 60,
numeric_precision: null,
numeric_scale: null,
is_generated: false,
is_nullable: true,
is_unique: false,
is_primary_key: false,
has_auto_increment: false,
foreign_key_column: null,
foreign_key_table: null,
},
{
name: 'request_path',

@@ -292,0 +309,0 @@ table: 'page_visits',

@@ -101,2 +101,3 @@ import knex, { Knex } from 'knex';

{ table: 'users', column: 'password' },
{ table: 'users', column: 'status' },
]);

@@ -359,2 +360,19 @@ });

},
{
name: 'status',
table: 'users',
data_type: 'varchar',
default_value: 'active',
max_length: 60,
numeric_precision: null,
numeric_scale: null,
is_generated: false,
is_nullable: true,
is_unique: false,
is_primary_key: false,
has_auto_increment: false,
foreign_key_column: null,
foreign_key_table: null,
comment: '',
},
]);

@@ -361,0 +379,0 @@ });

@@ -76,2 +76,3 @@ import knex, { Knex } from 'knex';

{ table: 'USERS', column: 'PASSWORD' },
{ table: 'USERS', column: 'STATUS' },
{ table: 'PAGE_VISITS', column: 'REQUEST_PATH' },

@@ -287,2 +288,19 @@ { table: 'PAGE_VISITS', column: 'USER_AGENT' },

{
name: 'STATUS',
table: 'USERS',
data_type: 'VARCHAR2',
default_value: 'active',
max_length: 60,
numeric_precision: null,
numeric_scale: null,
is_generated: false,
is_nullable: true,
is_unique: false,
is_primary_key: false,
has_auto_increment: false,
foreign_key_column: null,
foreign_key_table: null,
comment: null,
},
{
name: 'CREATED_AT',

@@ -289,0 +307,0 @@ table: 'PAGE_VISITS',

@@ -73,2 +73,3 @@ import knex, { Knex } from 'knex';

{ table: 'users', column: 'password' },
{ table: 'users', column: 'status' },
{ table: 'camelCase', column: 'primaryKey' },

@@ -93,2 +94,3 @@ { table: 'users', column: 'email' },

{ table: 'users', column: 'password' },
{ table: 'users', column: 'status' },
{ table: 'camelCase', column: 'primaryKey' },

@@ -410,2 +412,21 @@ { table: 'users', column: 'email' },

},
{
name: 'status',
table: 'users',
data_type: 'character varying',
default_value: 'active',
max_length: 60,
numeric_precision: null,
numeric_scale: null,
is_generated: false,
is_nullable: true,
is_unique: false,
is_primary_key: false,
has_auto_increment: false,
foreign_key_column: null,
foreign_key_table: null,
comment: null,
schema: 'public',
foreign_key_schema: null,
},
]);

@@ -412,0 +433,0 @@ });

@@ -64,10 +64,10 @@ import knex, { Knex } from 'knex';

'CREATE TABLE "users" (\n' +
'\t"id" INTEGER NOT NULL,\n' +
'\t"team_id" integer NOT NULL,\n' +
'\t"email" varchar(100),\n' +
'\t"password" varchar(60),\n' +
'\tPRIMARY KEY("id" AUTOINCREMENT),\n' +
'\tFOREIGN KEY("team_id") REFERENCES "teams"("id")\n' +
'\tON UPDATE CASCADE\n' +
'\tON DELETE CASCADE\n' +
'\t"id"\tINTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n' +
'\t"team_id"\tinteger NOT NULL,\n' +
'\t"email"\tvarchar(100),\n' +
'\t"password"\tvarchar(60),\n' +
`\t"status"\tvarchar(60) DEFAULT 'active',\n` +
'\tFOREIGN KEY("team_id") REFERENCES "teams"("id") ' +
'ON UPDATE CASCADE ' +
'ON DELETE CASCADE\n' +
')',

@@ -120,2 +120,3 @@ },

{ table: 'users', column: 'password' },
{ table: 'users', column: 'status' },
]);

@@ -364,2 +365,18 @@ });

},
{
name: 'status',
table: 'users',
data_type: 'varchar',
default_value: 'active',
max_length: 60,
numeric_precision: null,
numeric_scale: null,
is_generated: false,
is_nullable: true,
is_unique: false,
is_primary_key: false,
has_auto_increment: false,
foreign_key_column: null,
foreign_key_table: null,
},
]);

@@ -366,0 +383,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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