@sqb/postgres-dialect 5.0.6 → 5.0.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 +2 -2
- package/postgres-serializer.js +16 -5
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/postgres-dialect",
|
|
3
3
|
"description": "SQB serialization extension for PostgreSQL database",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.7",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"tslib": "^2.8.1"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"@sqb/builder": "^5.0.
|
|
11
|
+
"@sqb/builder": "^5.0.7"
|
|
12
12
|
},
|
|
13
13
|
"type": "module",
|
|
14
14
|
"module": "./index.js",
|
package/postgres-serializer.js
CHANGED
|
@@ -48,7 +48,7 @@ export class PostgresSerializer {
|
|
|
48
48
|
o.right.expression = 'null';
|
|
49
49
|
o.right.isParam = false;
|
|
50
50
|
}
|
|
51
|
-
if (o.operatorType ===
|
|
51
|
+
if (o.operatorType === OperatorType.eq)
|
|
52
52
|
return defFn(ctx, {
|
|
53
53
|
...o,
|
|
54
54
|
operatorType: OperatorType.is,
|
|
@@ -73,7 +73,8 @@ export class PostgresSerializer {
|
|
|
73
73
|
!Array.isArray(o.right.value)) {
|
|
74
74
|
o.right.value = [o.right.value];
|
|
75
75
|
}
|
|
76
|
-
if (o.operatorType ===
|
|
76
|
+
if (o.operatorType === OperatorType.in ||
|
|
77
|
+
o.operatorType === OperatorType.notIn) {
|
|
77
78
|
if (o.left.isArray && !o.right.isArray && o.right.isParam) {
|
|
78
79
|
const left = o.left;
|
|
79
80
|
const right = o.right;
|
|
@@ -81,13 +82,13 @@ export class PostgresSerializer {
|
|
|
81
82
|
return defFn(ctx, {
|
|
82
83
|
...o,
|
|
83
84
|
operatorType: OperatorType.eq,
|
|
84
|
-
symbol: o.operatorType ===
|
|
85
|
+
symbol: o.operatorType === OperatorType.notIn ? '!=' : '=',
|
|
85
86
|
left: right,
|
|
86
87
|
right: left,
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
if (o.left.isArray && o.right.isArray) {
|
|
90
|
-
if (o.operatorType ===
|
|
91
|
+
if (o.operatorType === OperatorType.notIn)
|
|
91
92
|
o.left.expression = 'not ' + o.left.expression;
|
|
92
93
|
return defFn(ctx, { ...o, symbol: '&&' });
|
|
93
94
|
}
|
|
@@ -96,10 +97,20 @@ export class PostgresSerializer {
|
|
|
96
97
|
return defFn(ctx, {
|
|
97
98
|
...o,
|
|
98
99
|
operatorType: OperatorType.eq,
|
|
99
|
-
symbol: o.operatorType ===
|
|
100
|
+
symbol: o.operatorType === OperatorType.notIn ? '!=' : '=',
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
}
|
|
104
|
+
if (o.operatorType === OperatorType.match) {
|
|
105
|
+
const config = o.customArgs
|
|
106
|
+
? typeof o.customArgs === 'object'
|
|
107
|
+
? o.customArgs
|
|
108
|
+
: String(o.customArgs)
|
|
109
|
+
: undefined;
|
|
110
|
+
o.symbol = '@@';
|
|
111
|
+
o.right.expression = `plainto_tsquery('${(config || 'simple').replace(/'/g, '"')}', ${o.right.expression})`;
|
|
112
|
+
return defFn(ctx, o);
|
|
113
|
+
}
|
|
103
114
|
}
|
|
104
115
|
return defFn(ctx, o);
|
|
105
116
|
}
|