dbgate-tools 5.1.4 → 5.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/SqlDumper.d.ts +3 -1
- package/lib/SqlDumper.js +12 -5
- package/lib/SqlGenerator.d.ts +1 -1
- package/lib/computeDiffRows.d.ts +1 -1
- package/lib/diffTools.d.ts +1 -1
- package/lib/nameTools.d.ts +1 -1
- package/lib/packageTools.d.ts +1 -1
- package/lib/preloadedRowsTools.d.ts +1 -1
- package/lib/schemaEditorTools.d.ts +1 -1
- package/lib/structureTools.d.ts +10 -1
- package/lib/structureTools.js +13 -1
- package/lib/tableTransforms.d.ts +1 -1
- package/package.json +3 -3
package/lib/SqlDumper.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { ColumnInfo, ConstraintInfo, EngineDriver, ForeignKeyInfo, FunctionInfo, NamedObjectInfo, PrimaryKeyInfo, ProcedureInfo, SqlDialect, TableInfo, TransformType, TriggerInfo, ViewInfo, IndexInfo, UniqueInfo, CheckInfo, AlterProcessor, SqlObjectInfo } from 'dbgate-types';
|
|
1
|
+
import type { ColumnInfo, ConstraintInfo, EngineDriver, ForeignKeyInfo, FunctionInfo, NamedObjectInfo, PrimaryKeyInfo, ProcedureInfo, SqlDialect, TableInfo, TransformType, TriggerInfo, ViewInfo, IndexInfo, UniqueInfo, CheckInfo, AlterProcessor, SqlObjectInfo } from 'dbgate-types';
|
|
2
2
|
export declare class SqlDumper implements AlterProcessor {
|
|
3
3
|
s: string;
|
|
4
4
|
driver: EngineDriver;
|
|
5
5
|
dialect: SqlDialect;
|
|
6
6
|
indentLevel: number;
|
|
7
|
+
static keywordsCase: string;
|
|
8
|
+
static convertKeywordCase(keyword: any): string;
|
|
7
9
|
constructor(driver: EngineDriver);
|
|
8
10
|
endCommand(): void;
|
|
9
11
|
putRaw(text: any): void;
|
package/lib/SqlDumper.js
CHANGED
|
@@ -18,6 +18,12 @@ class SqlDumper {
|
|
|
18
18
|
this.driver = driver;
|
|
19
19
|
this.dialect = driver.dialect;
|
|
20
20
|
}
|
|
21
|
+
static convertKeywordCase(keyword) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
if (this.keywordsCase == 'lowerCase')
|
|
24
|
+
return (_a = keyword === null || keyword === void 0 ? void 0 : keyword.toString()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
25
|
+
return (_b = keyword === null || keyword === void 0 ? void 0 : keyword.toString()) === null || _b === void 0 ? void 0 : _b.toUpperCase();
|
|
26
|
+
}
|
|
21
27
|
endCommand() {
|
|
22
28
|
this.putRaw(';\n');
|
|
23
29
|
}
|
|
@@ -42,11 +48,11 @@ class SqlDumper {
|
|
|
42
48
|
this.putRaw("'");
|
|
43
49
|
}
|
|
44
50
|
putByteArrayValue(value) {
|
|
45
|
-
this.
|
|
51
|
+
this.put('^null');
|
|
46
52
|
}
|
|
47
53
|
putValue(value) {
|
|
48
54
|
if (value === null)
|
|
49
|
-
this.
|
|
55
|
+
this.put('^null');
|
|
50
56
|
else if (value === true)
|
|
51
57
|
this.putRaw('1');
|
|
52
58
|
else if (value === false)
|
|
@@ -62,7 +68,7 @@ class SqlDumper {
|
|
|
62
68
|
else if ((0, isPlainObject_1.default)(value) || (0, isArray_1.default)(value))
|
|
63
69
|
this.putStringValue(JSON.stringify(value));
|
|
64
70
|
else
|
|
65
|
-
this.
|
|
71
|
+
this.put('^null');
|
|
66
72
|
}
|
|
67
73
|
putCmd(format, ...args) {
|
|
68
74
|
this.put(format, ...args);
|
|
@@ -83,7 +89,7 @@ class SqlDumper {
|
|
|
83
89
|
case 'k':
|
|
84
90
|
{
|
|
85
91
|
if (value) {
|
|
86
|
-
this.putRaw(
|
|
92
|
+
this.putRaw(SqlDumper.convertKeywordCase(value));
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
95
|
break;
|
|
@@ -120,7 +126,7 @@ class SqlDumper {
|
|
|
120
126
|
switch (c) {
|
|
121
127
|
case '^':
|
|
122
128
|
while (i < length && format[i].match(/[a-z0-9_]/i)) {
|
|
123
|
-
this.putRaw(format[i]
|
|
129
|
+
this.putRaw(SqlDumper.convertKeywordCase(format[i]));
|
|
124
130
|
i++;
|
|
125
131
|
}
|
|
126
132
|
break;
|
|
@@ -581,3 +587,4 @@ class SqlDumper {
|
|
|
581
587
|
}
|
|
582
588
|
}
|
|
583
589
|
exports.SqlDumper = SqlDumper;
|
|
590
|
+
SqlDumper.keywordsCase = 'upperCase';
|
package/lib/SqlGenerator.d.ts
CHANGED
package/lib/computeDiffRows.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DbDiffOptions, testEqualTables, testEqualSqlObjects } from './diffTools';
|
|
2
|
-
import { DatabaseInfo, EngineDriver, SqlObjectInfo, TableInfo } from 'dbgate-types';
|
|
2
|
+
import type { DatabaseInfo, EngineDriver, SqlObjectInfo, TableInfo } from 'dbgate-types';
|
|
3
3
|
export declare function computeDiffRowsCore(sourceList: any, targetList: any, testEqual: any): any[];
|
|
4
4
|
export declare const DbDiffCompareDefs: {
|
|
5
5
|
tables: {
|
package/lib/diffTools.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnInfo, DatabaseInfo, EngineDriver, SqlObjectInfo, TableInfo } from 'dbgate-types';
|
|
1
|
+
import type { ColumnInfo, DatabaseInfo, EngineDriver, SqlObjectInfo, TableInfo } from 'dbgate-types';
|
|
2
2
|
import { AlterPlan } from './alterPlan';
|
|
3
3
|
declare type DbDiffSchemaMode = 'strict' | 'ignore' | 'ignoreImplicit';
|
|
4
4
|
export interface DbDiffOptions {
|
package/lib/nameTools.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnInfo, DatabaseInfo, DatabaseInfoObjects, NamedObjectInfo, SqlDialect, TableInfo } from 'dbgate-types';
|
|
1
|
+
import type { ColumnInfo, DatabaseInfo, DatabaseInfoObjects, NamedObjectInfo, SqlDialect, TableInfo } from 'dbgate-types';
|
|
2
2
|
export declare function fullNameFromString(name: any): {
|
|
3
3
|
schemaName: any;
|
|
4
4
|
pureName: any;
|
package/lib/packageTools.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EngineDriver, ExtensionsDirectory } from 'dbgate-types';
|
|
1
|
+
import type { EngineDriver, ExtensionsDirectory } from 'dbgate-types';
|
|
2
2
|
export declare function extractShellApiPlugins(functionName: any, props: any): string[];
|
|
3
3
|
export declare function extractPackageName(name: any): string;
|
|
4
4
|
export declare function extractShellApiFunctionName(functionName: any): string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DatabaseInfo, EngineDriver } from 'dbgate-types';
|
|
1
|
+
import type { DatabaseInfo, EngineDriver } from 'dbgate-types';
|
|
2
2
|
export declare function enrichWithPreloadedRows(dbModel: DatabaseInfo, dbTarget: DatabaseInfo, conn: any, driver: EngineDriver): Promise<DatabaseInfo>;
|
package/lib/structureTools.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import { DatabaseInfo, TableInfo, ApplicationDefinition } from 'dbgate-types';
|
|
1
|
+
import type { DatabaseInfo, TableInfo, ApplicationDefinition, ViewInfo, CollectionInfo } from 'dbgate-types';
|
|
2
2
|
export declare function addTableDependencies(db: DatabaseInfo): DatabaseInfo;
|
|
3
3
|
export declare function extendTableInfo(table: TableInfo): TableInfo;
|
|
4
4
|
export declare function extendDatabaseInfo(db: DatabaseInfo): DatabaseInfo;
|
|
5
5
|
export declare function extendDatabaseInfoFromApps(db: DatabaseInfo, apps: ApplicationDefinition[]): DatabaseInfo;
|
|
6
6
|
export declare function isTableColumnUnique(table: TableInfo, column: string): boolean;
|
|
7
|
+
export declare function isTableInfo(obj: {
|
|
8
|
+
objectTypeField?: string;
|
|
9
|
+
}): obj is TableInfo;
|
|
10
|
+
export declare function isViewInfo(obj: {
|
|
11
|
+
objectTypeField?: string;
|
|
12
|
+
}): obj is ViewInfo;
|
|
13
|
+
export declare function isCollectionInfo(obj: {
|
|
14
|
+
objectTypeField?: string;
|
|
15
|
+
}): obj is CollectionInfo;
|
package/lib/structureTools.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isTableColumnUnique = exports.extendDatabaseInfoFromApps = exports.extendDatabaseInfo = exports.extendTableInfo = exports.addTableDependencies = void 0;
|
|
6
|
+
exports.isCollectionInfo = exports.isViewInfo = exports.isTableInfo = exports.isTableColumnUnique = exports.extendDatabaseInfoFromApps = exports.extendDatabaseInfo = exports.extendTableInfo = exports.addTableDependencies = void 0;
|
|
7
7
|
const flatten_1 = __importDefault(require("lodash/flatten"));
|
|
8
8
|
function addTableDependencies(db) {
|
|
9
9
|
const allForeignKeys = (0, flatten_1.default)(db.tables.map(x => x.foreignKeys || []));
|
|
@@ -45,3 +45,15 @@ function isTableColumnUnique(table, column) {
|
|
|
45
45
|
return false;
|
|
46
46
|
}
|
|
47
47
|
exports.isTableColumnUnique = isTableColumnUnique;
|
|
48
|
+
function isTableInfo(obj) {
|
|
49
|
+
return obj.objectTypeField == 'tables';
|
|
50
|
+
}
|
|
51
|
+
exports.isTableInfo = isTableInfo;
|
|
52
|
+
function isViewInfo(obj) {
|
|
53
|
+
return obj.objectTypeField == 'views';
|
|
54
|
+
}
|
|
55
|
+
exports.isViewInfo = isViewInfo;
|
|
56
|
+
function isCollectionInfo(obj) {
|
|
57
|
+
return obj.objectTypeField == 'collections';
|
|
58
|
+
}
|
|
59
|
+
exports.isCollectionInfo = isCollectionInfo;
|
package/lib/tableTransforms.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.1.
|
|
2
|
+
"version": "5.1.6",
|
|
3
3
|
"name": "dbgate-tools",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
],
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/node": "^13.7.0",
|
|
28
|
-
"dbgate-types": "^5.1.
|
|
28
|
+
"dbgate-types": "^5.1.6",
|
|
29
29
|
"jest": "^24.9.0",
|
|
30
30
|
"ts-jest": "^25.2.1",
|
|
31
31
|
"typescript": "^4.4.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"dbgate-query-splitter": "^4.9.2",
|
|
35
|
-
"dbgate-sqltree": "^5.1.
|
|
35
|
+
"dbgate-sqltree": "^5.1.6",
|
|
36
36
|
"debug": "^4.3.4",
|
|
37
37
|
"json-stable-stringify": "^1.0.1",
|
|
38
38
|
"lodash": "^4.17.21",
|