dbgate-tools 5.1.3 → 5.1.5
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 +4 -0
- package/lib/SqlDumper.js +18 -5
- package/lib/driverBase.d.ts +1 -0
- package/lib/driverBase.js +1 -0
- package/lib/structureTools.d.ts +10 -1
- package/lib/structureTools.js +13 -1
- package/package.json +4 -4
package/lib/SqlDumper.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export declare class SqlDumper implements AlterProcessor {
|
|
|
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;
|
|
@@ -16,6 +18,8 @@ export declare class SqlDumper implements AlterProcessor {
|
|
|
16
18
|
putFormattedList(c: any, collection: any): void;
|
|
17
19
|
put(format: string, ...args: any[]): void;
|
|
18
20
|
autoIncrement(): void;
|
|
21
|
+
createDatabase(name: string): void;
|
|
22
|
+
dropDatabase(name: string): void;
|
|
19
23
|
specialColumnOptions(column: any): void;
|
|
20
24
|
columnDefinition(column: ColumnInfo, { includeDefault, includeNullable, includeCollate }?: {
|
|
21
25
|
includeDefault?: boolean;
|
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;
|
|
@@ -170,6 +176,12 @@ class SqlDumper {
|
|
|
170
176
|
autoIncrement() {
|
|
171
177
|
this.put(' ^auto_increment');
|
|
172
178
|
}
|
|
179
|
+
createDatabase(name) {
|
|
180
|
+
this.putCmd('^create ^database %i', name);
|
|
181
|
+
}
|
|
182
|
+
dropDatabase(name) {
|
|
183
|
+
this.putCmd('^drop ^database %i', name);
|
|
184
|
+
}
|
|
173
185
|
specialColumnOptions(column) { }
|
|
174
186
|
columnDefinition(column, { includeDefault = true, includeNullable = true, includeCollate = true } = {}) {
|
|
175
187
|
var _a;
|
|
@@ -575,3 +587,4 @@ class SqlDumper {
|
|
|
575
587
|
}
|
|
576
588
|
}
|
|
577
589
|
exports.SqlDumper = SqlDumper;
|
|
590
|
+
SqlDumper.keywordsCase = 'upperCase';
|
package/lib/driverBase.d.ts
CHANGED
package/lib/driverBase.js
CHANGED
package/lib/structureTools.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import { DatabaseInfo, TableInfo, ApplicationDefinition } from 'dbgate-types';
|
|
1
|
+
import { 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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.1.
|
|
2
|
+
"version": "5.1.5",
|
|
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.5",
|
|
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
|
-
"dbgate-query-splitter": "^4.9.
|
|
35
|
-
"dbgate-sqltree": "^5.1.
|
|
34
|
+
"dbgate-query-splitter": "^4.9.2",
|
|
35
|
+
"dbgate-sqltree": "^5.1.5",
|
|
36
36
|
"debug": "^4.3.4",
|
|
37
37
|
"json-stable-stringify": "^1.0.1",
|
|
38
38
|
"lodash": "^4.17.21",
|