dbgate-tools 5.2.7-alpha.1 → 5.2.8
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.js +16 -7
- package/lib/alterPlan.d.ts +1 -1
- package/lib/diffTools.d.ts +1 -1
- package/lib/structureTools.js +3 -0
- package/package.json +3 -3
package/lib/SqlDumper.js
CHANGED
|
@@ -12,18 +12,18 @@ const isArray_1 = __importDefault(require("lodash/isArray"));
|
|
|
12
12
|
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
13
13
|
const v1_1 = __importDefault(require("uuid/v1"));
|
|
14
14
|
class SqlDumper {
|
|
15
|
-
constructor(driver) {
|
|
16
|
-
this.s = '';
|
|
17
|
-
this.indentLevel = 0;
|
|
18
|
-
this.driver = driver;
|
|
19
|
-
this.dialect = driver.dialect;
|
|
20
|
-
}
|
|
21
15
|
static convertKeywordCase(keyword) {
|
|
22
16
|
var _a, _b;
|
|
23
17
|
if (this.keywordsCase == 'lowerCase')
|
|
24
18
|
return (_a = keyword === null || keyword === void 0 ? void 0 : keyword.toString()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
25
19
|
return (_b = keyword === null || keyword === void 0 ? void 0 : keyword.toString()) === null || _b === void 0 ? void 0 : _b.toUpperCase();
|
|
26
20
|
}
|
|
21
|
+
constructor(driver) {
|
|
22
|
+
this.s = '';
|
|
23
|
+
this.indentLevel = 0;
|
|
24
|
+
this.driver = driver;
|
|
25
|
+
this.dialect = driver.dialect;
|
|
26
|
+
}
|
|
27
27
|
endCommand() {
|
|
28
28
|
this.putRaw(';\n');
|
|
29
29
|
}
|
|
@@ -192,7 +192,16 @@ class SqlDumper {
|
|
|
192
192
|
this.put(' ^persisted');
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
|
-
|
|
195
|
+
const type = column.dataType || this.dialect.fallbackDataType;
|
|
196
|
+
const typeWithValues = type.match(/([^(]+)(\(.+[^)]\))/);
|
|
197
|
+
if (typeWithValues === null || typeWithValues === void 0 ? void 0 : typeWithValues.length) {
|
|
198
|
+
typeWithValues.shift();
|
|
199
|
+
this.putRaw(SqlDumper.convertKeywordCase(typeWithValues.shift()));
|
|
200
|
+
this.putRaw(typeWithValues);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
this.putRaw(SqlDumper.convertKeywordCase(type));
|
|
204
|
+
}
|
|
196
205
|
if (column.autoIncrement) {
|
|
197
206
|
this.autoIncrement();
|
|
198
207
|
}
|
package/lib/alterPlan.d.ts
CHANGED
|
@@ -70,7 +70,7 @@ interface AlterOperation_FillPreloadedRows {
|
|
|
70
70
|
key: string[];
|
|
71
71
|
insertOnly: string[];
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
type AlterOperation = AlterOperation_CreateColumn | AlterOperation_ChangeColumn | AlterOperation_DropColumn | AlterOperation_CreateConstraint | AlterOperation_ChangeConstraint | AlterOperation_DropConstraint | AlterOperation_CreateTable | AlterOperation_DropTable | AlterOperation_RenameTable | AlterOperation_RenameColumn | AlterOperation_RenameConstraint | AlterOperation_CreateSqlObject | AlterOperation_DropSqlObject | AlterOperation_RecreateTable | AlterOperation_FillPreloadedRows;
|
|
74
74
|
export declare class AlterPlan {
|
|
75
75
|
wholeOldDb: DatabaseInfo;
|
|
76
76
|
wholeNewDb: DatabaseInfo;
|
package/lib/diffTools.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ColumnInfo, DatabaseInfo, EngineDriver, SqlObjectInfo, TableInfo } from 'dbgate-types';
|
|
2
2
|
import { AlterPlan } from './alterPlan';
|
|
3
|
-
|
|
3
|
+
type DbDiffSchemaMode = 'strict' | 'ignore' | 'ignoreImplicit';
|
|
4
4
|
export interface DbDiffOptions {
|
|
5
5
|
ignoreCase?: boolean;
|
|
6
6
|
schemaMode?: DbDiffSchemaMode;
|
package/lib/structureTools.js
CHANGED
|
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
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
|
+
if (!db.tables) {
|
|
10
|
+
return db;
|
|
11
|
+
}
|
|
9
12
|
const allForeignKeys = (0, flatten_1.default)(db.tables.map(x => x.foreignKeys || []));
|
|
10
13
|
return Object.assign(Object.assign({}, db), { tables: db.tables.map(table => (Object.assign(Object.assign({}, table), { dependencies: allForeignKeys.filter(x => x.refSchemaName == table.schemaName && x.refTableName == table.pureName) }))) });
|
|
11
14
|
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "5.2.
|
|
2
|
+
"version": "5.2.8",
|
|
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.2.
|
|
28
|
+
"dbgate-types": "^5.2.8",
|
|
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.3",
|
|
35
|
-
"dbgate-sqltree": "^5.2.
|
|
35
|
+
"dbgate-sqltree": "^5.2.8",
|
|
36
36
|
"debug": "^4.3.4",
|
|
37
37
|
"json-stable-stringify": "^1.0.1",
|
|
38
38
|
"lodash": "^4.17.21",
|