dbgate-sqltree 6.6.0 → 6.6.2

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.
@@ -78,6 +78,13 @@ function evaluateCondition(condition, values) {
78
78
  });
79
79
  return evaluateCondition(replaced, values);
80
80
  });
81
+ case 'in':
82
+ const value = extractRawValue((0, evaluateExpression_1.evaluateExpression)(condition.expr, values));
83
+ const list = condition.values;
84
+ if (Array.isArray(list)) {
85
+ return list.some(item => item == value);
86
+ }
87
+ return false;
81
88
  }
82
89
  }
83
90
  exports.evaluateCondition = evaluateCondition;
package/lib/utility.d.ts CHANGED
@@ -9,3 +9,6 @@ export declare function selectKeysFromTable(options: {
9
9
  keyColumns: [];
10
10
  loadKeys: any[][];
11
11
  }): Select;
12
+ export declare function createLogCompoudCondition(fieldFilters: {
13
+ [field: string]: string[];
14
+ }, timeColumn: string, timeFrom: number, timeTo: number): Condition;
package/lib/utility.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.selectKeysFromTable = exports.mergeConditions = exports.scriptToSql = exports.treeToSql = void 0;
3
+ exports.createLogCompoudCondition = 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();
@@ -81,3 +81,38 @@ function selectKeysFromTable(options) {
81
81
  return res;
82
82
  }
83
83
  exports.selectKeysFromTable = selectKeysFromTable;
84
+ function createLogCompoudCondition(fieldFilters, timeColumn, timeFrom, timeTo) {
85
+ const conditions = [
86
+ {
87
+ conditionType: 'binary',
88
+ operator: '>=',
89
+ left: { exprType: 'column', columnName: timeColumn },
90
+ right: { exprType: 'value', value: timeFrom },
91
+ },
92
+ {
93
+ conditionType: 'binary',
94
+ operator: '<=',
95
+ left: { exprType: 'column', columnName: timeColumn },
96
+ right: { exprType: 'value', value: timeTo },
97
+ },
98
+ ];
99
+ for (const [key, values] of Object.entries(fieldFilters)) {
100
+ if (values.length == 1 && values[0] == null) {
101
+ conditions.push({
102
+ conditionType: 'isNull',
103
+ expr: { exprType: 'column', columnName: key },
104
+ });
105
+ continue;
106
+ }
107
+ conditions.push({
108
+ conditionType: 'in',
109
+ expr: { exprType: 'column', columnName: key },
110
+ values,
111
+ });
112
+ }
113
+ return {
114
+ conditionType: 'and',
115
+ conditions,
116
+ };
117
+ }
118
+ exports.createLogCompoudCondition = createLogCompoudCondition;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "6.6.0",
2
+ "version": "6.6.2",
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.6.0",
30
+ "dbgate-types": "^6.6.2",
31
31
  "typescript": "^4.4.3"
32
32
  },
33
33
  "dependencies": {