sqlparser-devexpress 2.3.3 → 2.3.4
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 +4 -4
- package/src/debug.js +1 -1
- package/tests/parser.test.js +9 -7
package/package.json
CHANGED
package/src/core/converter.js
CHANGED
|
@@ -141,9 +141,9 @@ function DevExpressConverter() {
|
|
|
141
141
|
let comparison = [left, operatorToken, right];
|
|
142
142
|
|
|
143
143
|
if ((ast.left && isFunctionNullCheck(ast.left, true)) || (ast.value && isFunctionNullCheck(ast.value, false))) {
|
|
144
|
-
comparison = [[left, operatorToken, right], 'or', [left, operatorToken, null]];
|
|
144
|
+
comparison = [[left, operatorToken, right], 'or', [left, operatorToken, null, {type: "ISNULL", defaultValue: (ast.left ?? ast.value).args[1]?.value}]];
|
|
145
145
|
} else if (ast.right && isFunctionNullCheck(ast.right, true)) {
|
|
146
|
-
comparison = [[left, operatorToken, right], 'or', [right, operatorToken, null]];
|
|
146
|
+
comparison = [[left, operatorToken, right], 'or', [right, operatorToken, null, {type: "ISNULL", defaultValue: ast.right.args[1]?.value}]];
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
// Apply short-circuit evaluation if enabled
|
|
@@ -322,7 +322,7 @@ function DevExpressConverter() {
|
|
|
322
322
|
* @returns {boolean} True if the condition is always true.
|
|
323
323
|
*/
|
|
324
324
|
function isAlwaysTrue(condition) {
|
|
325
|
-
return Array.isArray(condition) && condition.length
|
|
325
|
+
return Array.isArray(condition) && condition.length >= 3 && evaluateExpression(...condition) == true;
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
/**
|
|
@@ -331,7 +331,7 @@ function DevExpressConverter() {
|
|
|
331
331
|
* @returns {boolean} True if the condition is always false.
|
|
332
332
|
*/
|
|
333
333
|
function isAlwaysFalse(condition) {
|
|
334
|
-
return Array.isArray(condition) && condition.length
|
|
334
|
+
return Array.isArray(condition) && condition.length >= 3 && evaluateExpression(...condition) == false;
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
/**
|
package/src/debug.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
// return convertToDevExpressFormat({ ast: astTree, resultObject: sampleData });
|
|
29
29
|
// }
|
|
30
30
|
|
|
31
|
-
// const devexpress = parseFilterString("
|
|
31
|
+
// const devexpress = parseFilterString("CompanyID = ISNULL({LeadDocument.CompanyID},0) OR (ISNULL(CompanyID,0) = 0))", sampleData);
|
|
32
32
|
// console.log("DevExpress Filter:", JSON.stringify(devexpress, null, 2));
|
|
33
33
|
// // const devexpress = parseFilterString("(RS2ID in ({LeadStatementGlobalRpt.StateID}) Or ({LeadStatementGlobalRpt.StateID} =0)) And (RS3ID in (0,{LeadStatementGlobalRpt.RegionID}) Or {LeadStatementGlobalRpt.RegionID} =0 )", sampleData);
|
|
34
34
|
|
package/tests/parser.test.js
CHANGED
|
@@ -137,11 +137,11 @@ describe("Parser SQL to dx Filter Builder", () => {
|
|
|
137
137
|
expected: [
|
|
138
138
|
["SourceID", "=", 2],
|
|
139
139
|
"or",
|
|
140
|
-
["SourceID", "=", null],
|
|
140
|
+
["SourceID", "=", null,{ "defaultValue": 0, "type": "ISNULL"}],
|
|
141
141
|
"or",
|
|
142
142
|
["SourceID", "=", 0],
|
|
143
143
|
"or",
|
|
144
|
-
["SourceID", "=", null]
|
|
144
|
+
["SourceID", "=", null,{ "defaultValue": 0, "type": "ISNULL"}]
|
|
145
145
|
]
|
|
146
146
|
},
|
|
147
147
|
{
|
|
@@ -153,14 +153,14 @@ describe("Parser SQL to dx Filter Builder", () => {
|
|
|
153
153
|
[
|
|
154
154
|
["CompanyID", "=", 0],
|
|
155
155
|
"or",
|
|
156
|
-
["CompanyID", "=", null]
|
|
156
|
+
["CompanyID", "=", null,{ "defaultValue": 0, "type": "ISNULL"}]
|
|
157
157
|
]
|
|
158
158
|
],
|
|
159
159
|
"and",
|
|
160
160
|
[
|
|
161
161
|
["IsSubdealer", "=", true],
|
|
162
162
|
"or",
|
|
163
|
-
["IsSubdealer", "=", null]
|
|
163
|
+
["IsSubdealer", "=", null,{ "defaultValue": 0, "type": "ISNULL"}]
|
|
164
164
|
]
|
|
165
165
|
]
|
|
166
166
|
},
|
|
@@ -187,7 +187,7 @@ describe("Parser SQL to dx Filter Builder", () => {
|
|
|
187
187
|
expected: [
|
|
188
188
|
["TicketID", "=", 123],
|
|
189
189
|
"or",
|
|
190
|
-
["TicketID", "=", null]
|
|
190
|
+
["TicketID", "=", null,{ "defaultValue": 0, "type": "ISNULL"}]
|
|
191
191
|
]
|
|
192
192
|
},
|
|
193
193
|
{
|
|
@@ -195,11 +195,13 @@ describe("Parser SQL to dx Filter Builder", () => {
|
|
|
195
195
|
expected: [
|
|
196
196
|
["CompanyID", "=", 7],
|
|
197
197
|
"or",
|
|
198
|
-
["CompanyID", "=", null],
|
|
198
|
+
["CompanyID", "=", null,{ "defaultValue": 0, "type": "ISNULL"}],
|
|
199
199
|
"or",
|
|
200
200
|
["CompanyID", "=", 0],
|
|
201
201
|
"or",
|
|
202
|
-
["CompanyID", "=", null
|
|
202
|
+
["CompanyID", "=", null,{ "defaultValue": 0, "type": "ISNULL"},
|
|
203
|
+
|
|
204
|
+
]
|
|
203
205
|
|
|
204
206
|
]
|
|
205
207
|
}
|