dbgate-sqltree 6.3.3 → 6.4.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/utility.d.ts +7 -1
- package/lib/utility.js +36 -1
- package/package.json +2 -2
package/lib/utility.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { EngineDriver, SqlDumper } from 'dbgate-types';
|
|
2
|
-
import { Command, Condition } from './types';
|
|
2
|
+
import { Command, Condition, Select } from './types';
|
|
3
3
|
export declare function treeToSql<T>(driver: EngineDriver, object: T, func: (dmp: SqlDumper, obj: T) => void): string;
|
|
4
4
|
export declare function scriptToSql(driver: EngineDriver, script: Command[]): string;
|
|
5
5
|
export declare function mergeConditions(condition1: Condition, condition2: Condition): Condition;
|
|
6
|
+
export declare function selectKeysFromTable(options: {
|
|
7
|
+
pureName: string;
|
|
8
|
+
schemaName: string;
|
|
9
|
+
keyColumns: [];
|
|
10
|
+
loadKeys: any[][];
|
|
11
|
+
}): Select;
|
package/lib/utility.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeConditions = exports.scriptToSql = exports.treeToSql = void 0;
|
|
3
|
+
exports.selectKeysFromTable = exports.mergeConditions = exports.scriptToSql = exports.treeToSql = void 0;
|
|
4
4
|
const dumpSqlCommand_1 = require("./dumpSqlCommand");
|
|
5
5
|
function treeToSql(driver, object, func) {
|
|
6
6
|
const dmp = driver.createDumper();
|
|
@@ -46,3 +46,38 @@ function mergeConditions(condition1, condition2) {
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
exports.mergeConditions = mergeConditions;
|
|
49
|
+
function selectKeysFromTable(options) {
|
|
50
|
+
const source = {
|
|
51
|
+
name: { pureName: options.pureName, schemaName: options.schemaName },
|
|
52
|
+
};
|
|
53
|
+
const res = {
|
|
54
|
+
commandType: 'select',
|
|
55
|
+
columns: options.keyColumns.map(col => ({
|
|
56
|
+
exprType: 'column',
|
|
57
|
+
columnName: col,
|
|
58
|
+
source,
|
|
59
|
+
})),
|
|
60
|
+
from: source,
|
|
61
|
+
where: {
|
|
62
|
+
conditionType: 'or',
|
|
63
|
+
conditions: options.loadKeys.map(key => ({
|
|
64
|
+
conditionType: 'and',
|
|
65
|
+
conditions: key.map((keyValue, index) => ({
|
|
66
|
+
conditionType: 'binary',
|
|
67
|
+
operator: '=',
|
|
68
|
+
left: {
|
|
69
|
+
exprType: 'column',
|
|
70
|
+
columnName: options.keyColumns[index],
|
|
71
|
+
source,
|
|
72
|
+
},
|
|
73
|
+
right: {
|
|
74
|
+
exprType: 'value',
|
|
75
|
+
value: keyValue,
|
|
76
|
+
},
|
|
77
|
+
})),
|
|
78
|
+
})),
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
return res;
|
|
82
|
+
}
|
|
83
|
+
exports.selectKeysFromTable = selectKeysFromTable;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "6.
|
|
2
|
+
"version": "6.4.1",
|
|
3
3
|
"name": "dbgate-sqltree",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"typings": "lib/index.d.ts",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^13.7.0",
|
|
30
|
-
"dbgate-types": "^6.
|
|
30
|
+
"dbgate-types": "^6.4.1",
|
|
31
31
|
"typescript": "^4.4.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|