dbgate-sqltree 7.0.0 → 7.0.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.
- package/lib/dumpSqlCondition.js +23 -6
- package/package.json +2 -2
package/lib/dumpSqlCondition.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.dumpSqlCondition = void 0;
|
|
|
4
4
|
const dumpSqlExpression_1 = require("./dumpSqlExpression");
|
|
5
5
|
const dumpSqlCommand_1 = require("./dumpSqlCommand");
|
|
6
6
|
function dumpSqlCondition(dmp, condition) {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f;
|
|
7
8
|
switch (condition.conditionType) {
|
|
8
9
|
case 'binary':
|
|
9
10
|
(0, dumpSqlExpression_1.dumpSqlExpression)(dmp, condition.left);
|
|
@@ -19,14 +20,30 @@ function dumpSqlCondition(dmp, condition) {
|
|
|
19
20
|
dmp.put(' ^is ^not ^null');
|
|
20
21
|
break;
|
|
21
22
|
case 'isEmpty':
|
|
22
|
-
|
|
23
|
-
(0
|
|
24
|
-
|
|
23
|
+
// Use DATALENGTH for MSSQL TEXT/NTEXT/IMAGE columns to avoid TRIM error
|
|
24
|
+
if ((_b = (_a = dmp.dialect).useDatalengthForEmptyString) === null || _b === void 0 ? void 0 : _b.call(_a, (_c = condition.expr) === null || _c === void 0 ? void 0 : _c['dataType'])) {
|
|
25
|
+
dmp.put('^datalength(');
|
|
26
|
+
(0, dumpSqlExpression_1.dumpSqlExpression)(dmp, condition.expr);
|
|
27
|
+
dmp.put(') = 0');
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
dmp.put('^trim(');
|
|
31
|
+
(0, dumpSqlExpression_1.dumpSqlExpression)(dmp, condition.expr);
|
|
32
|
+
dmp.put(") = ''");
|
|
33
|
+
}
|
|
25
34
|
break;
|
|
26
35
|
case 'isNotEmpty':
|
|
27
|
-
|
|
28
|
-
(0
|
|
29
|
-
|
|
36
|
+
// Use DATALENGTH for MSSQL TEXT/NTEXT/IMAGE columns to avoid TRIM error
|
|
37
|
+
if ((_e = (_d = dmp.dialect).useDatalengthForEmptyString) === null || _e === void 0 ? void 0 : _e.call(_d, (_f = condition.expr) === null || _f === void 0 ? void 0 : _f['dataType'])) {
|
|
38
|
+
dmp.put('^datalength(');
|
|
39
|
+
(0, dumpSqlExpression_1.dumpSqlExpression)(dmp, condition.expr);
|
|
40
|
+
dmp.put(') > 0');
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
dmp.put('^trim(');
|
|
44
|
+
(0, dumpSqlExpression_1.dumpSqlExpression)(dmp, condition.expr);
|
|
45
|
+
dmp.put(") <> ''");
|
|
46
|
+
}
|
|
30
47
|
break;
|
|
31
48
|
case 'and':
|
|
32
49
|
case 'or':
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "7.0.
|
|
2
|
+
"version": "7.0.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": "^7.0.
|
|
30
|
+
"dbgate-types": "^7.0.2",
|
|
31
31
|
"typescript": "^4.4.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|