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.1 to 1.5.2

20

dist/dialects/mssql.d.ts

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

import { ForeignKey } from '../types/foreign-key';
declare type RawColumn = {
table: string;
name: string;
data_type: string;
max_length: number | null;
numeric_precision: number | null;
numeric_scale: number | null;
is_generated: boolean | null;
is_nullable: 'YES' | 'NO';
default_value: string | null;
is_unique: 'YES' | 'NO';
is_primary_key: 'YES' | 'NO';
has_auto_increment: 'YES' | 'NO';
foreign_key_table: string | null;
foreign_key_column: string | null;
generation_expression: string | null;
};
export declare function rawColumnToColumn(rawColumn: RawColumn): Column;
export declare function parseDefaultValue(value: string | null): string | number | null;
export default class MSSQL implements SchemaInspector {

@@ -54,1 +73,2 @@ knex: Knex;

}
export {};

3

dist/dialects/mssql.js

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseDefaultValue = exports.rawColumnToColumn = void 0;
function rawColumnToColumn(rawColumn) {

@@ -55,2 +56,3 @@ return __assign(__assign({}, rawColumn), { default_value: parseDefaultValue(rawColumn.default_value) ||

}
exports.rawColumnToColumn = rawColumnToColumn;
function parseDefaultValue(value) {

@@ -63,2 +65,3 @@ if (!value)

}
exports.parseDefaultValue = parseDefaultValue;
var MSSQL = /** @class */ (function () {

@@ -65,0 +68,0 @@ function MSSQL(knex) {

@@ -5,2 +5,24 @@ import { Knex } from 'knex';

import { Column } from '../types/column';
declare type RawColumn = {
TABLE_NAME: string;
COLUMN_NAME: string;
COLUMN_DEFAULT: any | null;
DATA_TYPE: string;
CHARACTER_MAXIMUM_LENGTH: number | null;
NUMERIC_PRECISION: number | null;
NUMERIC_SCALE: number | null;
IS_NULLABLE: 'YES' | 'NO';
COLLATION_NAME: string | null;
COLUMN_COMMENT: string | null;
REFERENCED_TABLE_NAME: string | null;
REFERENCED_COLUMN_NAME: string | null;
UPDATE_RULE: string | null;
DELETE_RULE: string | null;
COLUMN_KEY: 'PRI' | 'UNI' | null;
EXTRA: 'auto_increment' | 'STORED GENERATED' | 'VIRTUAL GENERATED' | null;
CONSTRAINT_NAME: 'PRIMARY' | null;
GENERATION_EXPRESSION: string;
};
export declare function rawColumnToColumn(rawColumn: RawColumn): Column;
export declare function parseDefaultValue(value: any): any;
export default class MySQL implements SchemaInspector {

@@ -55,1 +77,2 @@ knex: Knex;

}
export {};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseDefaultValue = exports.rawColumnToColumn = void 0;
function rawColumnToColumn(rawColumn) {

@@ -73,2 +74,3 @@ var _a, _b;

}
exports.rawColumnToColumn = rawColumnToColumn;
function parseDefaultValue(value) {

@@ -78,2 +80,3 @@ // MariaDB returns string NULL for not-nullable varchar fields

}
exports.parseDefaultValue = parseDefaultValue;
var MySQL = /** @class */ (function () {

@@ -80,0 +83,0 @@ function MySQL(knex) {

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

import { ForeignKey } from '../types/foreign-key';
declare type RawColumn = {
TABLE_NAME: string;
COLUMN_NAME: string;
DATA_DEFAULT: any | null;
DATA_TYPE: string;
DATA_LENGTH: number | null;
DATA_PRECISION: number | null;
DATA_SCALE: number | null;
NULLABLE: 'Y' | 'N';
COLUMN_COMMENT: string | null;
REFERENCED_TABLE_NAME: string | null;
REFERENCED_COLUMN_NAME: string | null;
CONSTRAINT_TYPE: 'P' | 'U' | null;
VIRTUAL_COLUMN: 'YES' | 'NO';
IDENTITY_COLUMN: 'YES' | 'NO';
};
export declare function rawColumnToColumn(rawColumn: RawColumn): Column;
export default class oracleDB implements SchemaInspector {

@@ -47,1 +64,2 @@ knex: Knex;

}
export {};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.rawColumnToColumn = void 0;
function rawColumnToColumn(rawColumn) {

@@ -59,2 +60,3 @@ return {

}
exports.rawColumnToColumn = rawColumnToColumn;
var oracleDB = /** @class */ (function () {

@@ -61,0 +63,0 @@ function oracleDB(knex) {

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

import { ForeignKey } from '../types/foreign-key';
declare type RawColumn = {
column_name: string;
table_name: string;
table_schema: string;
data_type: string;
column_default: any | null;
character_maximum_length: number | null;
is_generated: 'YES' | 'NO';
is_nullable: 'YES' | 'NO';
is_unique: boolean;
is_primary: boolean;
is_identity: 'YES' | 'NO';
generation_expression: null | string;
numeric_precision: null | number;
numeric_scale: null | number;
serial: null | string;
column_comment: string | null;
foreign_key_schema: null | string;
foreign_key_table: null | string;
foreign_key_column: null | string;
};
export declare function rawColumnToColumn(rawColumn: RawColumn): Column;
/**
* Converts Postgres default value to JS
* Eg `'example'::character varying` => `example`
*/
export declare function parseDefaultValue(type: string | null): any;
export default class Postgres implements SchemaInspector {

@@ -53,1 +80,2 @@ knex: Knex;

}
export {};

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseDefaultValue = exports.rawColumnToColumn = void 0;
function rawColumnToColumn(rawColumn) {

@@ -62,2 +63,3 @@ return {

}
exports.rawColumnToColumn = rawColumnToColumn;
/**

@@ -80,2 +82,3 @@ * Converts Postgres default value to JS

}
exports.parseDefaultValue = parseDefaultValue;
var Postgres = /** @class */ (function () {

@@ -82,0 +85,0 @@ function Postgres(knex) {

4

lib/dialects/mssql.ts

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

function rawColumnToColumn(rawColumn: RawColumn): Column {
export function rawColumnToColumn(rawColumn: RawColumn): Column {
return {

@@ -48,3 +48,3 @@ ...rawColumn,

function parseDefaultValue(value: string | null) {
export function parseDefaultValue(value: string | null) {
if (!value) return null;

@@ -51,0 +51,0 @@

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

function rawColumnToColumn(rawColumn: RawColumn): Column {
export function rawColumnToColumn(rawColumn: RawColumn): Column {
return {

@@ -62,3 +62,3 @@ name: rawColumn.COLUMN_NAME,

function parseDefaultValue(value: any) {
export function parseDefaultValue(value: any) {
// MariaDB returns string NULL for not-nullable varchar fields

@@ -65,0 +65,0 @@ return /null|NULL/.test(value) ? null : value;

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

function rawColumnToColumn(rawColumn: RawColumn): Column {
export function rawColumnToColumn(rawColumn: RawColumn): Column {
return {

@@ -31,0 +31,0 @@ name: rawColumn.COLUMN_NAME,

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

function rawColumnToColumn(rawColumn: RawColumn): Column {
export function rawColumnToColumn(rawColumn: RawColumn): Column {
return {

@@ -65,3 +65,3 @@ name: rawColumn.column_name,

*/
function parseDefaultValue(type: string | null) {
export function parseDefaultValue(type: string | null) {
if (!type) return null;

@@ -68,0 +68,0 @@ if (type.startsWith('nextval(')) return type;

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

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

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