dbgate-tools 6.5.6 → 6.6.1
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/DatabaseAnalyser.d.ts +8 -3
- package/lib/DatabaseAnalyser.js +9 -6
- package/lib/SqlGenerator.js +1 -1
- package/lib/alterPlan.d.ts +1 -0
- package/lib/alterPlan.js +18 -8
- package/lib/createBulkInsertStreamBase.js +5 -5
- package/lib/diffTools.d.ts +1 -0
- package/lib/diffTools.js +5 -3
- package/lib/driverBase.d.ts +5 -0
- package/lib/driverBase.js +8 -1
- package/lib/filterBehaviours.d.ts +1 -0
- package/lib/filterBehaviours.js +26 -2
- package/lib/schemaInfoTools.d.ts +0 -1
- package/lib/schemaInfoTools.js +10 -11
- package/lib/stringTools.js +53 -0
- package/package.json +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DatabaseHandle, DatabaseInfo, DatabaseModification, EngineDriver, SqlDialect } from 'dbgate-types';
|
|
2
2
|
import { type Logger } from 'pinomin';
|
|
3
|
-
export declare class DatabaseAnalyser {
|
|
4
|
-
dbhan: DatabaseHandle
|
|
3
|
+
export declare class DatabaseAnalyser<TClient = any> {
|
|
4
|
+
dbhan: DatabaseHandle<TClient>;
|
|
5
5
|
driver: EngineDriver;
|
|
6
6
|
structure: DatabaseInfo;
|
|
7
7
|
modifications: DatabaseModification[];
|
|
@@ -9,11 +9,16 @@ export declare class DatabaseAnalyser {
|
|
|
9
9
|
singleObjectId: string;
|
|
10
10
|
dialect: SqlDialect;
|
|
11
11
|
logger: Logger;
|
|
12
|
-
constructor(dbhan: DatabaseHandle
|
|
12
|
+
constructor(dbhan: DatabaseHandle<TClient>, driver: EngineDriver, version: any);
|
|
13
13
|
_runAnalysis(): Promise<DatabaseInfo>;
|
|
14
14
|
_getFastSnapshot(): Promise<DatabaseInfo>;
|
|
15
15
|
_computeSingleObjectId(): Promise<void>;
|
|
16
16
|
addEngineField(db: DatabaseInfo): DatabaseInfo;
|
|
17
|
+
getLogDbInfo(): {
|
|
18
|
+
database?: string;
|
|
19
|
+
engine: string;
|
|
20
|
+
conid?: string;
|
|
21
|
+
};
|
|
17
22
|
fullAnalysis(): Promise<DatabaseInfo>;
|
|
18
23
|
singleObjectAnalysis(name: any, typeField: any): Promise<any>;
|
|
19
24
|
incrementalAnalysis(structure: any): Promise<DatabaseInfo>;
|
package/lib/DatabaseAnalyser.js
CHANGED
|
@@ -73,8 +73,11 @@ class DatabaseAnalyser {
|
|
|
73
73
|
db.engine = this.driver.engine;
|
|
74
74
|
return db;
|
|
75
75
|
}
|
|
76
|
+
getLogDbInfo() {
|
|
77
|
+
return this.driver.getLogDbInfo(this.dbhan);
|
|
78
|
+
}
|
|
76
79
|
async fullAnalysis() {
|
|
77
|
-
logger.debug(
|
|
80
|
+
logger.debug(this.getLogDbInfo(), 'DBGM-00126 Performing full analysis');
|
|
78
81
|
const res = this.addEngineField(await this._runAnalysis());
|
|
79
82
|
// console.log('FULL ANALYSIS', res);
|
|
80
83
|
return res;
|
|
@@ -93,7 +96,7 @@ class DatabaseAnalyser {
|
|
|
93
96
|
return obj;
|
|
94
97
|
}
|
|
95
98
|
async incrementalAnalysis(structure) {
|
|
96
|
-
logger.info(
|
|
99
|
+
logger.info(this.getLogDbInfo(), 'DBGM-00127 Performing incremental analysis');
|
|
97
100
|
this.structure = structure;
|
|
98
101
|
const modifications = await this.getModifications();
|
|
99
102
|
if (modifications == null) {
|
|
@@ -116,7 +119,7 @@ class DatabaseAnalyser {
|
|
|
116
119
|
this.modifications = structureModifications;
|
|
117
120
|
if (structureWithRowCounts)
|
|
118
121
|
this.structure = structureWithRowCounts;
|
|
119
|
-
logger.info({ modifications: this.modifications }, 'DB modifications detected
|
|
122
|
+
logger.info({ ...this.getLogDbInfo(), modifications: this.modifications }, 'DBGM-00128 DB modifications detected');
|
|
120
123
|
return this.addEngineField(this.mergeAnalyseResult(await this._runAnalysis()));
|
|
121
124
|
}
|
|
122
125
|
mergeAnalyseResult(newlyAnalysed) {
|
|
@@ -246,7 +249,7 @@ class DatabaseAnalyser {
|
|
|
246
249
|
this.dbhan.feedback(obj);
|
|
247
250
|
}
|
|
248
251
|
if (obj && obj.analysingMessage) {
|
|
249
|
-
logger.debug(obj.analysingMessage);
|
|
252
|
+
logger.debug(this.getLogDbInfo(), obj.analysingMessage);
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
255
|
async getModifications() {
|
|
@@ -311,11 +314,11 @@ class DatabaseAnalyser {
|
|
|
311
314
|
}
|
|
312
315
|
try {
|
|
313
316
|
const res = await this.driver.query(this.dbhan, sql);
|
|
314
|
-
this.logger.debug({ rows: res.rows.length, template }, `Loaded analyser query`);
|
|
317
|
+
this.logger.debug({ ...this.getLogDbInfo(), rows: res.rows.length, template }, `DBGM-00129 Loaded analyser query`);
|
|
315
318
|
return res;
|
|
316
319
|
}
|
|
317
320
|
catch (err) {
|
|
318
|
-
logger.error((0, stringTools_1.extractErrorLogData)(err, { template }), 'Error running analyser query');
|
|
321
|
+
logger.error((0, stringTools_1.extractErrorLogData)(err, { template, ...this.getLogDbInfo() }), 'DBGM-00130 Error running analyser query');
|
|
319
322
|
return {
|
|
320
323
|
rows: [],
|
|
321
324
|
isError: true,
|
package/lib/SqlGenerator.js
CHANGED
|
@@ -20,7 +20,7 @@ class SqlGenerator {
|
|
|
20
20
|
this.isTruncated = false;
|
|
21
21
|
this.isUnhandledException = false;
|
|
22
22
|
this.handleException = error => {
|
|
23
|
-
logger.error((0, stringTools_1.extractErrorLogData)(error), 'Unhandled error');
|
|
23
|
+
logger.error((0, stringTools_1.extractErrorLogData)(error), 'DBGM-00186 Unhandled error');
|
|
24
24
|
this.isUnhandledException = true;
|
|
25
25
|
};
|
|
26
26
|
this.dbinfo = (0, structureTools_1.extendDatabaseInfo)(dbinfo);
|
package/lib/alterPlan.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ export declare class AlterPlan {
|
|
|
114
114
|
fillPreloadedRows(table: NamedObjectInfo, oldRows: any[], newRows: any[], key: string[], insertOnly: string[], autoIncrementColumn: string): void;
|
|
115
115
|
setTableOption(table: TableInfo, optionName: string, optionValue: string): void;
|
|
116
116
|
run(processor: AlterProcessor): void;
|
|
117
|
+
_hasOnlyCommentChange(op: AlterOperation): boolean;
|
|
117
118
|
_getDependendColumnConstraints(column: ColumnInfo, dependencyDefinition: any): import("dbgate-types/dbinfo").PrimaryKeyInfo[];
|
|
118
119
|
_addLogicalDependencies(): AlterOperation[];
|
|
119
120
|
_transformToImplementedOps(): AlterOperation[];
|
package/lib/alterPlan.js
CHANGED
|
@@ -143,6 +143,12 @@ class AlterPlan {
|
|
|
143
143
|
runAlterOperation(op, processor);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
+
_hasOnlyCommentChange(op) {
|
|
147
|
+
if (op.operationType === 'changeColumn') {
|
|
148
|
+
return lodash_1.default.isEqual(lodash_1.default.omit(op.oldObject, ['columnComment', 'ordinal']), lodash_1.default.omit(op.newObject, ['columnComment', 'ordinal']));
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
146
152
|
_getDependendColumnConstraints(column, dependencyDefinition) {
|
|
147
153
|
const table = this.wholeOldDb.tables.find(x => x.pureName == column.pureName && x.schemaName == column.schemaName);
|
|
148
154
|
if (!table)
|
|
@@ -184,28 +190,32 @@ class AlterPlan {
|
|
|
184
190
|
]) {
|
|
185
191
|
if (op.operationType == testedOperationType) {
|
|
186
192
|
const constraints = this._getDependendColumnConstraints(testedObject, testedDependencies);
|
|
193
|
+
const ignoreContraints = this.dialect.safeCommentChanges && this._hasOnlyCommentChange(op);
|
|
187
194
|
// if (constraints.length > 0 && this.opts.noDropConstraint) {
|
|
188
195
|
// return [];
|
|
189
196
|
// }
|
|
190
|
-
const res = [
|
|
191
|
-
|
|
197
|
+
const res = [];
|
|
198
|
+
if (!ignoreContraints) {
|
|
199
|
+
res.push(...constraints.map(oldObject => {
|
|
192
200
|
const opRes = {
|
|
193
201
|
operationType: 'dropConstraint',
|
|
194
202
|
oldObject,
|
|
195
203
|
isRecreate: true,
|
|
196
204
|
};
|
|
197
205
|
return opRes;
|
|
198
|
-
})
|
|
199
|
-
|
|
200
|
-
|
|
206
|
+
}));
|
|
207
|
+
}
|
|
208
|
+
res.push(op);
|
|
209
|
+
if (!ignoreContraints) {
|
|
210
|
+
res.push(...lodash_1.default.reverse([...constraints]).map(newObject => {
|
|
201
211
|
const opRes = {
|
|
202
212
|
operationType: 'createConstraint',
|
|
203
213
|
newObject,
|
|
204
214
|
};
|
|
205
215
|
return opRes;
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
if (constraints.length > 0) {
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
if (!ignoreContraints && constraints.length > 0) {
|
|
209
219
|
this.recreates.constraints += 1;
|
|
210
220
|
}
|
|
211
221
|
return res;
|
|
@@ -42,20 +42,20 @@ function createBulkInsertStreamBase(driver, stream, dbhan, name, options) {
|
|
|
42
42
|
writable.structure = structure;
|
|
43
43
|
}
|
|
44
44
|
if (structure && options.dropIfExists) {
|
|
45
|
-
logger.info(`Dropping table ${fullNameQuoted}`);
|
|
45
|
+
logger.info(`DBGM-00123 Dropping table ${fullNameQuoted}`);
|
|
46
46
|
await driver.script(dbhan, `DROP TABLE ${fullNameQuoted}`);
|
|
47
47
|
}
|
|
48
48
|
if (options.createIfNotExists && (!structure || options.dropIfExists)) {
|
|
49
49
|
const dmp = driver.createDumper();
|
|
50
50
|
const createdTableInfo = driver.adaptTableInfo((0, tableTransforms_1.prepareTableForImport)({ ...writable.structure, ...name }));
|
|
51
51
|
dmp.createTable(createdTableInfo);
|
|
52
|
-
logger.info({ sql: dmp.s }, `Creating table ${fullNameQuoted}`);
|
|
52
|
+
logger.info({ sql: dmp.s }, `DBGM-00124 Creating table ${fullNameQuoted}`);
|
|
53
53
|
await driver.script(dbhan, dmp.s);
|
|
54
54
|
structure = await driver.analyseSingleTable(dbhan, name);
|
|
55
55
|
writable.structure = structure;
|
|
56
56
|
}
|
|
57
57
|
if (!writable.structure) {
|
|
58
|
-
throw new Error(`Error importing table - ${fullNameQuoted} not found`);
|
|
58
|
+
throw new Error(`DBGM-00125 Error importing table - ${fullNameQuoted} not found`);
|
|
59
59
|
}
|
|
60
60
|
if (options.truncate) {
|
|
61
61
|
await driver.script(dbhan, `TRUNCATE TABLE ${fullNameQuoted}`);
|
|
@@ -70,7 +70,7 @@ function createBulkInsertStreamBase(driver, stream, dbhan, name, options) {
|
|
|
70
70
|
}));
|
|
71
71
|
}
|
|
72
72
|
catch (err) {
|
|
73
|
-
logger.error((0, stringTools_1.extractErrorLogData)(err), 'Error during preparing bulk insert table, stopped');
|
|
73
|
+
logger.error((0, stringTools_1.extractErrorLogData)(err), 'DBGM-00184 Error during preparing bulk insert table, stopped');
|
|
74
74
|
writable.destroy(err);
|
|
75
75
|
}
|
|
76
76
|
};
|
|
@@ -121,7 +121,7 @@ function createBulkInsertStreamBase(driver, stream, dbhan, name, options) {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
catch (err) {
|
|
124
|
-
logger.error((0, stringTools_1.extractErrorLogData)(err), 'Error during base bulk insert, insert stopped');
|
|
124
|
+
logger.error((0, stringTools_1.extractErrorLogData)(err), 'DBGM-00185 Error during base bulk insert, insert stopped');
|
|
125
125
|
writable.destroy(err);
|
|
126
126
|
}
|
|
127
127
|
};
|
package/lib/diffTools.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface DbDiffOptions {
|
|
|
19
19
|
noRenameColumn?: boolean;
|
|
20
20
|
ignoreForeignKeyActions?: boolean;
|
|
21
21
|
ignoreDataTypes?: boolean;
|
|
22
|
+
ignoreComments?: boolean;
|
|
22
23
|
}
|
|
23
24
|
export declare function generateTablePairingId(table: TableInfo): TableInfo;
|
|
24
25
|
export declare function removeTablePairingId(table: TableInfo): TableInfo;
|
package/lib/diffTools.js
CHANGED
|
@@ -252,9 +252,11 @@ function testEqualColumns(a, b, checkName, checkDefault, opts = {}) {
|
|
|
252
252
|
console.debug(`Column ${a.pureName}.${a.columnName}, ${b.pureName}.${b.columnName}: different zerofill: ${a.isZerofill}, ${b.isZerofill}`);
|
|
253
253
|
return false;
|
|
254
254
|
}
|
|
255
|
-
if (
|
|
256
|
-
|
|
257
|
-
|
|
255
|
+
if (!opts.ignoreComments) {
|
|
256
|
+
if ((a.columnComment || '') != (b.columnComment || '')) {
|
|
257
|
+
console.debug(`Column ${a.pureName}.${a.columnName}, ${b.pureName}.${b.columnName}: different comment: ${a.columnComment}, ${b.columnComment}`);
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
258
260
|
}
|
|
259
261
|
if (!testEqualTypes(a, b, opts)) {
|
|
260
262
|
return false;
|
package/lib/driverBase.d.ts
CHANGED
|
@@ -53,4 +53,9 @@ export declare const driverBase: {
|
|
|
53
53
|
adaptTableInfo(table: any): any;
|
|
54
54
|
listSchemas(pool: any): Promise<any>;
|
|
55
55
|
writeQueryFromStream(dbhan: any, sql: any): Promise<any>;
|
|
56
|
+
getLogDbInfo(dbhan: any): {
|
|
57
|
+
database: any;
|
|
58
|
+
engine: any;
|
|
59
|
+
conid: any;
|
|
60
|
+
};
|
|
56
61
|
};
|
package/lib/driverBase.js
CHANGED
|
@@ -96,7 +96,7 @@ exports.driverBase = {
|
|
|
96
96
|
for (const sqlItem of (0, dbgate_query_splitter_1.splitQuery)(sql, this.getQuerySplitterOptions('script'))) {
|
|
97
97
|
try {
|
|
98
98
|
if (options === null || options === void 0 ? void 0 : options.logScriptItems) {
|
|
99
|
-
logger.info({ sql: (0, stringTools_1.getLimitedQuery)(sqlItem) }, 'Execute script item');
|
|
99
|
+
logger.info({ sql: (0, stringTools_1.getLimitedQuery)(sqlItem) }, 'DBGM-00131 Execute script item');
|
|
100
100
|
}
|
|
101
101
|
await this.query(pool, sqlItem, { discardResult: true, ...options === null || options === void 0 ? void 0 : options.queryOptions });
|
|
102
102
|
}
|
|
@@ -238,4 +238,11 @@ exports.driverBase = {
|
|
|
238
238
|
async writeQueryFromStream(dbhan, sql) {
|
|
239
239
|
return null;
|
|
240
240
|
},
|
|
241
|
+
getLogDbInfo(dbhan) {
|
|
242
|
+
return {
|
|
243
|
+
database: dbhan ? dbhan.database : undefined,
|
|
244
|
+
engine: this.engine,
|
|
245
|
+
conid: dbhan ? dbhan.conid : undefined,
|
|
246
|
+
};
|
|
247
|
+
},
|
|
241
248
|
};
|
|
@@ -5,6 +5,7 @@ export declare const logicalFilterBehaviour: FilterBehaviour;
|
|
|
5
5
|
export declare const datetimeFilterBehaviour: FilterBehaviour;
|
|
6
6
|
export declare const mongoFilterBehaviour: FilterBehaviour;
|
|
7
7
|
export declare const evalFilterBehaviour: FilterBehaviour;
|
|
8
|
+
export declare const firestoreFilterBehaviours: FilterBehaviour;
|
|
8
9
|
export declare const standardFilterBehaviours: {
|
|
9
10
|
[id: string]: FilterBehaviour;
|
|
10
11
|
};
|
package/lib/filterBehaviours.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.standardFilterBehaviours = exports.evalFilterBehaviour = exports.mongoFilterBehaviour = exports.datetimeFilterBehaviour = exports.logicalFilterBehaviour = exports.stringFilterBehaviour = exports.numberFilterBehaviour = void 0;
|
|
3
|
+
exports.standardFilterBehaviours = exports.firestoreFilterBehaviours = exports.evalFilterBehaviour = exports.mongoFilterBehaviour = exports.datetimeFilterBehaviour = exports.logicalFilterBehaviour = exports.stringFilterBehaviour = exports.numberFilterBehaviour = void 0;
|
|
4
4
|
exports.numberFilterBehaviour = {
|
|
5
5
|
supportEquals: true,
|
|
6
6
|
supportNumberLikeComparison: true,
|
|
@@ -21,6 +21,7 @@ exports.stringFilterBehaviour = {
|
|
|
21
21
|
exports.logicalFilterBehaviour = {
|
|
22
22
|
supportBooleanValues: true,
|
|
23
23
|
supportNullTesting: true,
|
|
24
|
+
supportBooleanOrNull: true,
|
|
24
25
|
supportSqlCondition: true,
|
|
25
26
|
};
|
|
26
27
|
exports.datetimeFilterBehaviour = {
|
|
@@ -31,7 +32,8 @@ exports.datetimeFilterBehaviour = {
|
|
|
31
32
|
};
|
|
32
33
|
exports.mongoFilterBehaviour = {
|
|
33
34
|
supportEquals: true,
|
|
34
|
-
|
|
35
|
+
supportEmptyArrayTesting: true,
|
|
36
|
+
supportNotEmptyArrayTesting: true,
|
|
35
37
|
supportNumberLikeComparison: true,
|
|
36
38
|
supportStringInclusion: true,
|
|
37
39
|
supportBooleanValues: true,
|
|
@@ -48,11 +50,33 @@ exports.evalFilterBehaviour = {
|
|
|
48
50
|
supportNullTesting: true,
|
|
49
51
|
allowStringToken: true,
|
|
50
52
|
};
|
|
53
|
+
exports.firestoreFilterBehaviours = {
|
|
54
|
+
supportEquals: true,
|
|
55
|
+
supportEmpty: false,
|
|
56
|
+
supportNumberLikeComparison: true,
|
|
57
|
+
supportDatetimeComparison: false,
|
|
58
|
+
supportNullTesting: true,
|
|
59
|
+
supportBooleanValues: true,
|
|
60
|
+
supportEmptyArrayTesting: true,
|
|
61
|
+
supportStringInclusion: false,
|
|
62
|
+
supportDatetimeSymbols: false,
|
|
63
|
+
supportExistsTesting: false,
|
|
64
|
+
supportSqlCondition: false,
|
|
65
|
+
allowStringToken: true,
|
|
66
|
+
allowNumberToken: true,
|
|
67
|
+
allowHexString: true,
|
|
68
|
+
allowNumberDualTesting: false,
|
|
69
|
+
allowObjectIdTesting: false,
|
|
70
|
+
passBooleans: true,
|
|
71
|
+
passNumbers: true,
|
|
72
|
+
disableOr: true,
|
|
73
|
+
};
|
|
51
74
|
exports.standardFilterBehaviours = {
|
|
52
75
|
numberFilterBehaviour: exports.numberFilterBehaviour,
|
|
53
76
|
stringFilterBehaviour: exports.stringFilterBehaviour,
|
|
54
77
|
logicalFilterBehaviour: exports.logicalFilterBehaviour,
|
|
55
78
|
datetimeFilterBehaviour: exports.datetimeFilterBehaviour,
|
|
56
79
|
mongoFilterBehaviour: exports.mongoFilterBehaviour,
|
|
80
|
+
firestoreFilterBehaviours: exports.firestoreFilterBehaviours,
|
|
57
81
|
evalFilterBehaviour: exports.evalFilterBehaviour,
|
|
58
82
|
};
|
package/lib/schemaInfoTools.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export declare function splitCompositeDbName(name: string): {
|
|
|
7
7
|
};
|
|
8
8
|
export declare function extractDbNameFromComposite(name: string): string;
|
|
9
9
|
export declare function extractSchemaNameFromComposite(name: string): string;
|
|
10
|
-
export declare function dbNameLogCategory(database: string): string;
|
|
11
10
|
export declare function compositeDbNameIfNeeded(connnection: {
|
|
12
11
|
useSeparateSchemas: boolean;
|
|
13
12
|
}, database: string, schema: string): string;
|
package/lib/schemaInfoTools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.compositeDbNameIfNeeded = exports.
|
|
3
|
+
exports.compositeDbNameIfNeeded = exports.extractSchemaNameFromComposite = exports.extractDbNameFromComposite = exports.splitCompositeDbName = exports.isCompositeDbName = exports.findDefaultSchema = void 0;
|
|
4
4
|
function findDefaultSchema(schemaList, dialect, schemaInStorage = null) {
|
|
5
5
|
var _a;
|
|
6
6
|
if (!schemaList) {
|
|
@@ -39,16 +39,15 @@ function extractSchemaNameFromComposite(name) {
|
|
|
39
39
|
return (_a = splitCompositeDbName(name)) === null || _a === void 0 ? void 0 : _a.schema;
|
|
40
40
|
}
|
|
41
41
|
exports.extractSchemaNameFromComposite = extractSchemaNameFromComposite;
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
exports.dbNameLogCategory = dbNameLogCategory;
|
|
42
|
+
// export function getDbNameLogFace(database: string): string {
|
|
43
|
+
// if (isCompositeDbName(database)) {
|
|
44
|
+
// return '~composite';
|
|
45
|
+
// }
|
|
46
|
+
// if (database) {
|
|
47
|
+
// return '~simple';
|
|
48
|
+
// }
|
|
49
|
+
// return '~nodb';
|
|
50
|
+
// }
|
|
52
51
|
function compositeDbNameIfNeeded(connnection, database, schema) {
|
|
53
52
|
if (connnection === null || connnection === void 0 ? void 0 : connnection.useSeparateSchemas) {
|
|
54
53
|
return `${database}::${schema}`;
|
package/lib/stringTools.js
CHANGED
|
@@ -60,6 +60,35 @@ function parseCellValue(value, editorTypes) {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseGeopointAsDollar) {
|
|
64
|
+
const m = value.match(/^([\d\.]+)\s*°\s*([NS]),\s*([\d\.]+)\s*°\s*([EW])$/i);
|
|
65
|
+
if (m) {
|
|
66
|
+
let latitude = parseFloat(m[1]);
|
|
67
|
+
const latDir = m[2].toUpperCase();
|
|
68
|
+
let longitude = parseFloat(m[3]);
|
|
69
|
+
const lonDir = m[4].toUpperCase();
|
|
70
|
+
if (latDir === 'S')
|
|
71
|
+
latitude = -latitude;
|
|
72
|
+
if (lonDir === 'W')
|
|
73
|
+
longitude = -longitude;
|
|
74
|
+
return {
|
|
75
|
+
$geoPoint: {
|
|
76
|
+
latitude,
|
|
77
|
+
longitude,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseFsDocumentRefAsDollar) {
|
|
83
|
+
const trimmedValue = value.replace(/\s/g, '');
|
|
84
|
+
if (trimmedValue.startsWith('$ref:')) {
|
|
85
|
+
return {
|
|
86
|
+
$fsDocumentRef: {
|
|
87
|
+
documentPath: trimmedValue.slice(5),
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
63
92
|
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseJsonNull) {
|
|
64
93
|
if (value == 'null')
|
|
65
94
|
return null;
|
|
@@ -140,6 +169,7 @@ function stringifyJsonToGrid(value) {
|
|
|
140
169
|
return { value: '(JSON)', gridStyle: 'nullCellStyle' };
|
|
141
170
|
}
|
|
142
171
|
function stringifyCellValue(value, intent, editorTypes, gridFormattingOptions, jsonParsedValue) {
|
|
172
|
+
var _a;
|
|
143
173
|
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseSqlNull) {
|
|
144
174
|
if (value === null) {
|
|
145
175
|
switch (intent) {
|
|
@@ -214,6 +244,29 @@ function stringifyCellValue(value, intent, editorTypes, gridFormattingOptions, j
|
|
|
214
244
|
}
|
|
215
245
|
}
|
|
216
246
|
}
|
|
247
|
+
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseGeopointAsDollar) {
|
|
248
|
+
if (value === null || value === void 0 ? void 0 : value.$geoPoint) {
|
|
249
|
+
const { latitude, longitude } = value.$geoPoint;
|
|
250
|
+
if ((0, isNumber_1.default)(latitude) && (0, isNumber_1.default)(longitude)) {
|
|
251
|
+
const latAbs = Math.abs(latitude);
|
|
252
|
+
const lonAbs = Math.abs(longitude);
|
|
253
|
+
const latDir = latitude >= 0 ? 'N' : 'S';
|
|
254
|
+
const lonDir = longitude >= 0 ? 'E' : 'W';
|
|
255
|
+
return {
|
|
256
|
+
value: `${latAbs}° ${latDir}, ${lonAbs}° ${lonDir}`,
|
|
257
|
+
gridStyle: 'valueCellStyle',
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
if (editorTypes === null || editorTypes === void 0 ? void 0 : editorTypes.parseFsDocumentRefAsDollar) {
|
|
263
|
+
if (value === null || value === void 0 ? void 0 : value.$fsDocumentRef) {
|
|
264
|
+
return {
|
|
265
|
+
value: `$ref: ${(_a = value.$fsDocumentRef.documentPath) !== null && _a !== void 0 ? _a : ''}`,
|
|
266
|
+
gridStyle: 'valueCellStyle',
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
}
|
|
217
270
|
if ((0, isArray_1.default)(value)) {
|
|
218
271
|
switch (intent) {
|
|
219
272
|
case 'gridCellIntent':
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "6.
|
|
2
|
+
"version": "6.6.1",
|
|
3
3
|
"name": "dbgate-tools",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
],
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/node": "^13.7.0",
|
|
29
|
-
"dbgate-types": "^6.
|
|
29
|
+
"dbgate-types": "^6.6.1",
|
|
30
30
|
"jest": "^28.1.3",
|
|
31
31
|
"ts-jest": "^28.0.7",
|
|
32
32
|
"typescript": "^4.4.3"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"dbgate-query-splitter": "^4.11.5",
|
|
36
|
-
"dbgate-sqltree": "^6.
|
|
36
|
+
"dbgate-sqltree": "^6.6.1",
|
|
37
37
|
"debug": "^4.3.4",
|
|
38
38
|
"json-stable-stringify": "^1.0.1",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
40
|
-
"pinomin": "^1.0.
|
|
40
|
+
"pinomin": "^1.0.5",
|
|
41
41
|
"toposort": "^2.0.2",
|
|
42
42
|
"uuid": "^3.4.0"
|
|
43
43
|
}
|