dbgate-sqltree 5.2.2 → 5.2.4-alpha.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.
@@ -4,7 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.evaluateCondition = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
7
+ const cloneDeepWith_1 = __importDefault(require("lodash/cloneDeepWith"));
8
+ const escapeRegExp_1 = __importDefault(require("lodash/escapeRegExp"));
8
9
  const evaluateExpression_1 = require("./evaluateExpression");
9
10
  function isEmpty(value) {
10
11
  if (value == null)
@@ -16,7 +17,7 @@ function isLike(value, test) {
16
17
  return false;
17
18
  if (!test)
18
19
  return false;
19
- const regex = new RegExp(`^${lodash_1.default.escapeRegExp(test).replace(/%/g, '.*')}$`, 'i');
20
+ const regex = new RegExp(`^${(0, escapeRegExp_1.default)(test).replace(/%/g, '.*')}$`, 'i');
20
21
  const res = !!value.toString().match(regex);
21
22
  return res;
22
23
  }
@@ -60,6 +61,17 @@ function evaluateCondition(condition, values) {
60
61
  return !isLike((0, evaluateExpression_1.evaluateExpression)(condition.left, values), (0, evaluateExpression_1.evaluateExpression)(condition.right, values));
61
62
  case 'not':
62
63
  return !evaluateCondition(condition.condition, values);
64
+ case 'anyColumnPass':
65
+ return Object.keys(values).some(columnName => {
66
+ const replaced = (0, cloneDeepWith_1.default)(condition.placeholderCondition, (expr) => {
67
+ if (expr.exprType == 'placeholder')
68
+ return {
69
+ exprType: 'column',
70
+ columnName,
71
+ };
72
+ });
73
+ return evaluateCondition(replaced, values);
74
+ });
63
75
  }
64
76
  }
65
77
  exports.evaluateCondition = evaluateCondition;
package/lib/types.d.ts CHANGED
@@ -86,7 +86,11 @@ export interface RawTemplateCondition {
86
86
  templateSql: string;
87
87
  expr: Expression;
88
88
  }
89
- export declare type Condition = BinaryCondition | NotCondition | TestCondition | CompoudCondition | LikeCondition | ExistsCondition | NotExistsCondition | BetweenCondition | InCondition | RawTemplateCondition;
89
+ export interface AnyColumnPassEvalOnlyCondition {
90
+ conditionType: 'anyColumnPass';
91
+ placeholderCondition: Condition;
92
+ }
93
+ export declare type Condition = BinaryCondition | NotCondition | TestCondition | CompoudCondition | LikeCondition | ExistsCondition | NotExistsCondition | BetweenCondition | InCondition | RawTemplateCondition | AnyColumnPassEvalOnlyCondition;
90
94
  export interface Source {
91
95
  name?: NamedObjectInfo;
92
96
  alias?: string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.2.2",
2
+ "version": "5.2.4-alpha.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": "^5.2.2",
30
+ "dbgate-types": "^5.2.4-alpha.1",
31
31
  "typescript": "^4.4.3"
32
32
  },
33
33
  "dependencies": {