dbgate-filterparser 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.
Files changed (2) hide show
  1. package/lib/parseFilter.js +17 -3
  2. package/package.json +3 -3
@@ -51,6 +51,17 @@ const binaryCondition = (operator, numberDualTesting = false) => value => {
51
51
  },
52
52
  };
53
53
  };
54
+ const simpleEqualCondition = () => value => ({
55
+ conditionType: 'binary',
56
+ operator: '=',
57
+ left: {
58
+ exprType: 'placeholder',
59
+ },
60
+ right: {
61
+ exprType: 'value',
62
+ value,
63
+ },
64
+ });
54
65
  const likeCondition = (conditionType, likeString) => value => ({
55
66
  conditionType,
56
67
  left: {
@@ -299,6 +310,7 @@ const createParser = (filterBehaviour) => {
299
310
  .map(Number)
300
311
  .desc('number'),
301
312
  objectid: () => (0, common_1.token)(parsimmon_1.default.regexp(/ObjectId\(['"]?[0-9a-f]{24}['"]?\)/)).desc('ObjectId'),
313
+ objectidstr: () => (0, common_1.token)(parsimmon_1.default.regexp(/[0-9a-f]{24}/)).desc('ObjectId string'),
302
314
  hexstring: () => (0, common_1.token)(parsimmon_1.default.regexp(/0x(([0-9a-fA-F][0-9a-fA-F])+)/, 1))
303
315
  .map(x => ({
304
316
  type: 'Buffer',
@@ -312,6 +324,7 @@ const createParser = (filterBehaviour) => {
312
324
  value: r => parsimmon_1.default.alt(...allowedValues.map(x => r[x])),
313
325
  valueTestEq: r => r.value.map(binaryCondition('=')),
314
326
  hexTestEq: r => r.hexstring.map(binaryCondition('=')),
327
+ valueTestObjectIdStr: r => r.objectidstr.map(simpleEqualCondition()),
315
328
  valueTestStr: r => r.value.map(likeCondition('like', '%#VALUE#%')),
316
329
  valueTestNum: r => r.number.map(numberTestCondition()),
317
330
  valueTestObjectId: r => r.objectid.map(objectIdTestCondition()),
@@ -439,12 +452,13 @@ const createParser = (filterBehaviour) => {
439
452
  allowedElements.push('true', 'false', 'trueNum', 'falseNum');
440
453
  }
441
454
  }
442
- if (filterBehaviour.allowNumberDualTesting) {
443
- allowedElements.push('valueTestNum');
444
- }
445
455
  if (filterBehaviour.allowObjectIdTesting) {
456
+ allowedElements.push('valueTestObjectIdStr');
446
457
  allowedElements.push('valueTestObjectId');
447
458
  }
459
+ if (filterBehaviour.allowNumberDualTesting) {
460
+ allowedElements.push('valueTestNum');
461
+ }
448
462
  // must be last
449
463
  if (filterBehaviour.allowStringToken) {
450
464
  allowedElements.push('valueTestStr');
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "6.3.3",
2
+ "version": "6.4.1",
3
3
  "name": "dbgate-filterparser",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
@@ -13,7 +13,7 @@
13
13
  "lib"
14
14
  ],
15
15
  "devDependencies": {
16
- "dbgate-types": "^6.3.3",
16
+ "dbgate-types": "^6.4.1",
17
17
  "@types/jest": "^25.1.4",
18
18
  "@types/node": "^13.7.0",
19
19
  "jest": "^28.1.3",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@types/parsimmon": "^1.10.1",
25
- "dbgate-tools": "^6.3.3",
25
+ "dbgate-tools": "^6.4.1",
26
26
  "lodash": "^4.17.21",
27
27
  "date-fns": "^4.1.0",
28
28
  "moment": "^2.24.0",