sqlparser-devexpress 2.5.6 → 2.5.7
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/package.json +1 -1
- package/src/core/converter.js +18 -2
- package/tests/parser.test.js +24 -0
package/package.json
CHANGED
package/src/core/converter.js
CHANGED
|
@@ -364,11 +364,27 @@ function DevExpressConverter() {
|
|
|
364
364
|
let operatorToken = operator === "IN" ? '=' : operator === "NOT IN" ? '!=' : operator;
|
|
365
365
|
let joinOperatorToken = operator === "IN" ? 'or' : operator === "NOT IN" ? 'and' : operator;
|
|
366
366
|
let field = convertValue(ast.field);
|
|
367
|
+
|
|
368
|
+
// When the field itself is an ISNULL(column, default) check, preserve the
|
|
369
|
+
// null-fallback semantics instead of silently collapsing it to the bare column.
|
|
370
|
+
const isFieldNullCheck = isFunctionNullCheck(ast.field, true);
|
|
371
|
+
const nullCheckArg = isFieldNullCheck ? ast.field.args[1]?.value : undefined;
|
|
372
|
+
|
|
373
|
+
const buildEntry = (val) => {
|
|
374
|
+
const base = [field, operatorToken, val];
|
|
375
|
+
if (!isFieldNullCheck) return base;
|
|
376
|
+
|
|
377
|
+
if (normalizeBool(val) == normalizeBool(nullCheckArg)) {
|
|
378
|
+
return [base, 'or', [field, operatorToken, null, { type: "ISNULL", position: "column", defaultValue: nullCheckArg }, null]];
|
|
379
|
+
}
|
|
380
|
+
return [...base, { type: "ISNULL", position: "column", defaultValue: nullCheckArg }, val];
|
|
381
|
+
};
|
|
382
|
+
|
|
367
383
|
if (Array.isArray(resolvedValue) && resolvedValue.length) {
|
|
368
|
-
return resolvedValue.flatMap(i => [
|
|
384
|
+
return resolvedValue.flatMap(i => [buildEntry(i), joinOperatorToken]).slice(0, -1);
|
|
369
385
|
}
|
|
370
386
|
|
|
371
|
-
return
|
|
387
|
+
return buildEntry(resolvedValue);
|
|
372
388
|
}
|
|
373
389
|
|
|
374
390
|
/**
|
package/tests/parser.test.js
CHANGED
|
@@ -381,6 +381,28 @@ describe("Parser SQL to dx Filter Builder", () => {
|
|
|
381
381
|
expected: [
|
|
382
382
|
"AllowSubDealer", "=", true, { "type": "ISNULL", "position": "column", "defaultValue": 0 }, true
|
|
383
383
|
]
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
input: "(CompanyID = {SingleStepTransferDocument.CompanyID} OR {SingleStepTransferDocument.CompanyID} = 0 OR ISNULL(CompanyID,0) = 0) AND ((ISNULL(IsSubdealer,0)) IN ({SingleStepTransferDocument.AllowedSubdealer}))",
|
|
387
|
+
expected: [
|
|
388
|
+
[
|
|
389
|
+
[ "CompanyID", "=", 2, ],
|
|
390
|
+
"or",
|
|
391
|
+
[
|
|
392
|
+
[ "CompanyID", "=", 0, ],
|
|
393
|
+
"or",
|
|
394
|
+
[ "CompanyID", "=", null, { "defaultValue": 0, "position": "column", "type": "ISNULL", }, null, ],
|
|
395
|
+
"or",
|
|
396
|
+
[ "CompanyID", "=", false, ],
|
|
397
|
+
],
|
|
398
|
+
],
|
|
399
|
+
"and",
|
|
400
|
+
[
|
|
401
|
+
[ "IsSubdealer", "=", false, ],
|
|
402
|
+
"or",
|
|
403
|
+
[ "IsSubdealer", "=", null, { "defaultValue": 0, "position": "column", "type": "ISNULL", }, null, ]
|
|
404
|
+
]
|
|
405
|
+
]
|
|
384
406
|
},
|
|
385
407
|
{
|
|
386
408
|
input: "ISNULL(AllowSubDealer,1) = {LeadDocument.AllowSubDealer}",
|
|
@@ -495,6 +517,8 @@ describe("Parser SQL to dx Filter Builder", () => {
|
|
|
495
517
|
|
|
496
518
|
|
|
497
519
|
const sampleData = {
|
|
520
|
+
"SingleStepTransferDocument.CompanyID": 2,
|
|
521
|
+
"SingleStepTransferDocument.AllowedSubdealer": false,
|
|
498
522
|
"Example.ZeroValue": 0,
|
|
499
523
|
"CoreEntity0022.CompanyGroupID": 42,
|
|
500
524
|
"CoreEntity0022.BranchID": 7,
|