@sqb/postgres-dialect 4.14.0 → 4.15.0
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/esm/index.js +5 -3
- package/esm/postgres-serializer.js +13 -9
- package/package.json +22 -16
- package/cjs/package.json +0 -3
package/esm/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const builder_1 = require("@sqb/builder");
|
|
4
|
+
const postgres_serializer_js_1 = require("./postgres-serializer.js");
|
|
5
|
+
builder_1.SerializerRegistry.register(new postgres_serializer_js_1.PostgresSerializer());
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostgresSerializer = void 0;
|
|
4
|
+
const builder_1 = require("@sqb/builder");
|
|
2
5
|
const reservedWords = ['comment'];
|
|
3
|
-
|
|
6
|
+
class PostgresSerializer {
|
|
4
7
|
constructor() {
|
|
5
8
|
this.dialect = 'postgres';
|
|
6
9
|
}
|
|
@@ -9,11 +12,11 @@ export class PostgresSerializer {
|
|
|
9
12
|
}
|
|
10
13
|
serialize(ctx, type, o, defFn) {
|
|
11
14
|
switch (type) {
|
|
12
|
-
case SerializationType.SELECT_QUERY:
|
|
15
|
+
case builder_1.SerializationType.SELECT_QUERY:
|
|
13
16
|
return this._serializeSelect(ctx, o, defFn);
|
|
14
|
-
case SerializationType.COMPARISON_EXPRESSION:
|
|
17
|
+
case builder_1.SerializationType.COMPARISON_EXPRESSION:
|
|
15
18
|
return this._serializeComparison(ctx, o, defFn);
|
|
16
|
-
case SerializationType.EXTERNAL_PARAMETER:
|
|
19
|
+
case builder_1.SerializationType.EXTERNAL_PARAMETER:
|
|
17
20
|
return this._serializeParameter(ctx, o, defFn);
|
|
18
21
|
default:
|
|
19
22
|
return undefined;
|
|
@@ -34,9 +37,9 @@ export class PostgresSerializer {
|
|
|
34
37
|
if (!Array.isArray(o.right)) {
|
|
35
38
|
if (o.right.expression.toLowerCase() === 'null') {
|
|
36
39
|
if (o.operatorType === 'eq')
|
|
37
|
-
return defFn(ctx, { ...o, operatorType: OperatorType.is, symbol: 'is' });
|
|
40
|
+
return defFn(ctx, { ...o, operatorType: builder_1.OperatorType.is, symbol: 'is' });
|
|
38
41
|
if (o.operatorType === 'ne')
|
|
39
|
-
return defFn(ctx, { ...o, operatorType: OperatorType.isNot, symbol: 'is not' });
|
|
42
|
+
return defFn(ctx, { ...o, operatorType: builder_1.OperatorType.isNot, symbol: 'is not' });
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
if (o.left.isParam && o.left.isArray && o.left.value != null && !Array.isArray(o.left.value)) {
|
|
@@ -52,7 +55,7 @@ export class PostgresSerializer {
|
|
|
52
55
|
left.expression = 'ANY(' + left.expression + ')';
|
|
53
56
|
return defFn(ctx, {
|
|
54
57
|
...o,
|
|
55
|
-
operatorType: OperatorType.eq,
|
|
58
|
+
operatorType: builder_1.OperatorType.eq,
|
|
56
59
|
symbol: o.operatorType === 'notIn' ? '!=' : '=',
|
|
57
60
|
left: right,
|
|
58
61
|
right: left,
|
|
@@ -67,7 +70,7 @@ export class PostgresSerializer {
|
|
|
67
70
|
o.right.expression = 'ANY(' + o.right.expression + ')';
|
|
68
71
|
return defFn(ctx, {
|
|
69
72
|
...o,
|
|
70
|
-
operatorType: OperatorType.eq,
|
|
73
|
+
operatorType: builder_1.OperatorType.eq,
|
|
71
74
|
symbol: o.operatorType === 'notIn' ? '!=' : '=',
|
|
72
75
|
});
|
|
73
76
|
}
|
|
@@ -81,3 +84,4 @@ export class PostgresSerializer {
|
|
|
81
84
|
return '$' + ctx.preparedParams.length;
|
|
82
85
|
}
|
|
83
86
|
}
|
|
87
|
+
exports.PostgresSerializer = PostgresSerializer;
|
package/package.json
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/postgres-dialect",
|
|
3
3
|
"description": "SQB serialization extension for PostgreSQL database",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.15.0",
|
|
5
5
|
"author": "Panates",
|
|
6
|
-
"contributors": [
|
|
7
|
-
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
8
|
-
"Ilker Gurelli <i.gurelli@panates.com>"
|
|
9
|
-
],
|
|
10
6
|
"license": "Apache-2.0",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/sqbjs/sqb.git",
|
|
14
|
-
"directory": "packages/postgres-dialect"
|
|
15
|
-
},
|
|
16
|
-
"type": "module",
|
|
17
|
-
"module": "./esm/index.js",
|
|
18
|
-
"main": "./cjs/index.js",
|
|
19
|
-
"types": "./types/index.d.ts",
|
|
20
7
|
"scripts": {
|
|
21
8
|
"compile": "tsc",
|
|
22
9
|
"prebuild": "npm run lint && npm run clean",
|
|
23
10
|
"build": "npm run build:cjs && npm run build:esm",
|
|
24
11
|
"build:cjs": "tsc -b tsconfig-build-cjs.json",
|
|
25
12
|
"build:esm": "tsc -b tsconfig-build-esm.json",
|
|
26
|
-
"postbuild": "cp README.md package.json ../../LICENSE ../../build/postgres-dialect
|
|
13
|
+
"postbuild": "cp README.md package.json ../../LICENSE ../../build/postgres-dialect",
|
|
27
14
|
"lint": "eslint . --max-warnings=0",
|
|
28
15
|
"lint:fix": "eslint . --max-warnings=0 --fix",
|
|
29
16
|
"format": "prettier . --write --log-level=warn",
|
|
@@ -35,7 +22,26 @@
|
|
|
35
22
|
"clean:cover": "rimraf ../../coverage/postgres-dialect"
|
|
36
23
|
},
|
|
37
24
|
"peerDependencies": {
|
|
38
|
-
"@sqb/builder": "^4.
|
|
25
|
+
"@sqb/builder": "^4.15.0"
|
|
26
|
+
},
|
|
27
|
+
"main": "./cjs/index.js",
|
|
28
|
+
"module": "./esm/index.js",
|
|
29
|
+
"types": "./types/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"require": "./cjs/index.js",
|
|
33
|
+
"import": "./esm/index.js",
|
|
34
|
+
"types": "./types/index.d.ts"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"contributors": [
|
|
38
|
+
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
39
|
+
"Ilker Gurelli <i.gurelli@panates.com>"
|
|
40
|
+
],
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "https://github.com/sqbjs/sqb.git",
|
|
44
|
+
"directory": "packages/postgres-dialect"
|
|
39
45
|
},
|
|
40
46
|
"engines": {
|
|
41
47
|
"node": ">=16.0",
|
package/cjs/package.json
DELETED