@sqb/postgres-dialect 4.11.3 → 4.12.1
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/README.md +9 -24
- package/cjs/postgres-serializer.js +5 -6
- package/esm/postgres-serializer.js +6 -7
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -18,12 +18,12 @@ SQB is an extensible, multi-dialect SQL query builder and Database connection wr
|
|
|
18
18
|
|
|
19
19
|
## Main goals
|
|
20
20
|
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
21
|
+
- Single code base for any sql based database
|
|
22
|
+
- Powerful and simplified query coding scheme
|
|
23
|
+
- Fast applications with low memory requirements
|
|
24
|
+
- Let applications work with large data tables efficiently
|
|
25
|
+
- Support latest JavaScript language standards
|
|
26
|
+
- Lightweight and extensible framework.
|
|
27
27
|
|
|
28
28
|
You can report bugs and discuss features on the [GitHub issues](https://github.com/sqbjs/sqb/issues) page
|
|
29
29
|
|
|
@@ -39,40 +39,25 @@ $ npm install @sqb/postgres-dialect --save
|
|
|
39
39
|
|
|
40
40
|
## Node Compatibility
|
|
41
41
|
|
|
42
|
-
-
|
|
42
|
+
- node >= 16.x
|
|
43
43
|
|
|
44
44
|
### License
|
|
45
45
|
|
|
46
46
|
SQB is available under [MIT](LICENSE) license.
|
|
47
47
|
|
|
48
48
|
[npm-image]: https://img.shields.io/npm/v/@sqb/postgres-dialect.svg
|
|
49
|
-
|
|
50
49
|
[npm-url]: https://npmjs.org/package/@sqb/postgres-dialect
|
|
51
|
-
|
|
52
50
|
[travis-image]: https://img.shields.io/travis/sqbjs/@sqb/postgres-dialect/master.svg
|
|
53
|
-
|
|
54
51
|
[travis-url]: https://travis-ci.org/sqbjs/@sqb/postgres-dialect
|
|
55
|
-
|
|
56
52
|
[coveralls-image]: https://img.shields.io/coveralls/sqbjs/@sqb/postgres-dialect/master.svg
|
|
57
|
-
|
|
58
53
|
[coveralls-url]: https://coveralls.io/r/sqbjs/@sqb/postgres-dialect
|
|
59
|
-
|
|
60
54
|
[downloads-image]: https://img.shields.io/npm/dm/@sqb/postgres-dialect.svg
|
|
61
|
-
|
|
62
55
|
[downloads-url]: https://npmjs.org/package/@sqb/postgres-dialect
|
|
63
|
-
|
|
64
56
|
[gitter-image]: https://badges.gitter.im/sqbjs/@sqb/postgres-dialect.svg
|
|
65
|
-
|
|
66
57
|
[gitter-url]: https://gitter.im/sqbjs/@sqb/postgres-dialect?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
|
67
|
-
|
|
68
58
|
[dependencies-image]: https://david-dm.org/sqbjs/@sqb/postgres-dialect/status.svg
|
|
69
|
-
|
|
70
|
-
[dependencies-url]:https://david-dm.org/sqbjs/@sqb/postgres-dialect
|
|
71
|
-
|
|
59
|
+
[dependencies-url]: https://david-dm.org/sqbjs/@sqb/postgres-dialect
|
|
72
60
|
[devdependencies-image]: https://david-dm.org/sqbjs/@sqb/postgres-dialect/dev-status.svg
|
|
73
|
-
|
|
74
|
-
[devdependencies-url]:https://david-dm.org/sqbjs/@sqb/postgres-dialect?type=dev
|
|
75
|
-
|
|
61
|
+
[devdependencies-url]: https://david-dm.org/sqbjs/@sqb/postgres-dialect?type=dev
|
|
76
62
|
[quality-image]: http://npm.packagequality.com/shield/@sqb/postgres-dialect.png
|
|
77
|
-
|
|
78
63
|
[quality-url]: http://packagequality.com/#?package=@sqb/postgres-dialect
|
|
@@ -8,8 +8,7 @@ class PostgresSerializer {
|
|
|
8
8
|
this.dialect = 'postgres';
|
|
9
9
|
}
|
|
10
10
|
isReservedWord(ctx, s) {
|
|
11
|
-
return s && typeof s === 'string' &&
|
|
12
|
-
reservedWords.includes(s.toLowerCase());
|
|
11
|
+
return s && typeof s === 'string' && reservedWords.includes(s.toLowerCase());
|
|
13
12
|
}
|
|
14
13
|
serialize(ctx, type, o, defFn) {
|
|
15
14
|
switch (type) {
|
|
@@ -24,7 +23,7 @@ class PostgresSerializer {
|
|
|
24
23
|
_serializeSelect(ctx, o, defFn) {
|
|
25
24
|
let out = defFn(ctx, o);
|
|
26
25
|
const limit = o.limit || 0;
|
|
27
|
-
const offset = Math.max(
|
|
26
|
+
const offset = Math.max(o.offset || 0, 0);
|
|
28
27
|
if (limit)
|
|
29
28
|
out += '\nLIMIT ' + limit;
|
|
30
29
|
if (offset)
|
|
@@ -45,7 +44,7 @@ class PostgresSerializer {
|
|
|
45
44
|
o.left.value = [o.left.value];
|
|
46
45
|
if (o.right.isParam && o.right.isArray && o.right.value != null && !Array.isArray(o.right.value))
|
|
47
46
|
o.right.value = [o.right.value];
|
|
48
|
-
if (
|
|
47
|
+
if (o.operatorType === 'in' || o.operatorType === 'notIn') {
|
|
49
48
|
if (o.left.isArray && !o.right.isArray && o.right.isParam) {
|
|
50
49
|
const left = o.left;
|
|
51
50
|
const right = o.right;
|
|
@@ -55,7 +54,7 @@ class PostgresSerializer {
|
|
|
55
54
|
operatorType: builder_1.OperatorType.eq,
|
|
56
55
|
symbol: o.operatorType === 'notIn' ? '!=' : '=',
|
|
57
56
|
left: right,
|
|
58
|
-
right: left
|
|
57
|
+
right: left,
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
60
|
if (o.left.isArray && o.right.isArray) {
|
|
@@ -68,7 +67,7 @@ class PostgresSerializer {
|
|
|
68
67
|
return defFn(ctx, {
|
|
69
68
|
...o,
|
|
70
69
|
operatorType: builder_1.OperatorType.eq,
|
|
71
|
-
symbol: o.operatorType === 'notIn' ? '!=' : '='
|
|
70
|
+
symbol: o.operatorType === 'notIn' ? '!=' : '=',
|
|
72
71
|
});
|
|
73
72
|
}
|
|
74
73
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { OperatorType, SerializationType } from '@sqb/builder';
|
|
1
|
+
import { OperatorType, SerializationType, } from '@sqb/builder';
|
|
2
2
|
const reservedWords = ['comment'];
|
|
3
3
|
export class PostgresSerializer {
|
|
4
4
|
constructor() {
|
|
5
5
|
this.dialect = 'postgres';
|
|
6
6
|
}
|
|
7
7
|
isReservedWord(ctx, s) {
|
|
8
|
-
return s && typeof s === 'string' &&
|
|
9
|
-
reservedWords.includes(s.toLowerCase());
|
|
8
|
+
return s && typeof s === 'string' && reservedWords.includes(s.toLowerCase());
|
|
10
9
|
}
|
|
11
10
|
serialize(ctx, type, o, defFn) {
|
|
12
11
|
switch (type) {
|
|
@@ -21,7 +20,7 @@ export class PostgresSerializer {
|
|
|
21
20
|
_serializeSelect(ctx, o, defFn) {
|
|
22
21
|
let out = defFn(ctx, o);
|
|
23
22
|
const limit = o.limit || 0;
|
|
24
|
-
const offset = Math.max(
|
|
23
|
+
const offset = Math.max(o.offset || 0, 0);
|
|
25
24
|
if (limit)
|
|
26
25
|
out += '\nLIMIT ' + limit;
|
|
27
26
|
if (offset)
|
|
@@ -42,7 +41,7 @@ export class PostgresSerializer {
|
|
|
42
41
|
o.left.value = [o.left.value];
|
|
43
42
|
if (o.right.isParam && o.right.isArray && o.right.value != null && !Array.isArray(o.right.value))
|
|
44
43
|
o.right.value = [o.right.value];
|
|
45
|
-
if (
|
|
44
|
+
if (o.operatorType === 'in' || o.operatorType === 'notIn') {
|
|
46
45
|
if (o.left.isArray && !o.right.isArray && o.right.isParam) {
|
|
47
46
|
const left = o.left;
|
|
48
47
|
const right = o.right;
|
|
@@ -52,7 +51,7 @@ export class PostgresSerializer {
|
|
|
52
51
|
operatorType: OperatorType.eq,
|
|
53
52
|
symbol: o.operatorType === 'notIn' ? '!=' : '=',
|
|
54
53
|
left: right,
|
|
55
|
-
right: left
|
|
54
|
+
right: left,
|
|
56
55
|
});
|
|
57
56
|
}
|
|
58
57
|
if (o.left.isArray && o.right.isArray) {
|
|
@@ -65,7 +64,7 @@ export class PostgresSerializer {
|
|
|
65
64
|
return defFn(ctx, {
|
|
66
65
|
...o,
|
|
67
66
|
operatorType: OperatorType.eq,
|
|
68
|
-
symbol: o.operatorType === 'notIn' ? '!=' : '='
|
|
67
|
+
symbol: o.operatorType === 'notIn' ? '!=' : '=',
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
70
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/postgres-dialect",
|
|
3
3
|
"description": "SQB serialization extension for PostgreSQL database",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.12.1",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Eray Hanoglu <e.hanoglu@panates.com>",
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"build:esm": "tsc -b tsconfig-build-esm.json",
|
|
26
26
|
"postbuild": "cp README.md package.json ../../LICENSE ../../build/postgres-dialect && cp ../../package.cjs.json ../../build/postgres-dialect/cjs/package.json",
|
|
27
27
|
"lint": "eslint . --max-warnings=0",
|
|
28
|
+
"lint:fix": "eslint . --max-warnings=0 --fix",
|
|
29
|
+
"format": "prettier . --write --log-level=warn",
|
|
28
30
|
"test": "jest",
|
|
29
31
|
"cover": "jest --collect-coverage",
|
|
30
32
|
"clean": "npm run clean:src | npm run clean:dist | npm run clean:cover",
|
|
@@ -33,7 +35,7 @@
|
|
|
33
35
|
"clean:cover": "rimraf ../../coverage/postgres-dialect"
|
|
34
36
|
},
|
|
35
37
|
"peerDependencies": {
|
|
36
|
-
"@sqb/builder": "^4.
|
|
38
|
+
"@sqb/builder": "^4.12.1"
|
|
37
39
|
},
|
|
38
40
|
"engines": {
|
|
39
41
|
"node": ">=16.0",
|