@sqb/postgres-dialect 4.15.0 → 4.16.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 CHANGED
@@ -1,5 +1,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
+ import { SerializerRegistry } from '@sqb/builder';
2
+ import { PostgresSerializer } from './postgres-serializer.js';
3
+ SerializerRegistry.register(new PostgresSerializer());
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PostgresSerializer = void 0;
4
- const builder_1 = require("@sqb/builder");
1
+ import { OperatorType, SerializationType, } from '@sqb/builder';
5
2
  const reservedWords = ['comment'];
6
- class PostgresSerializer {
3
+ export class PostgresSerializer {
7
4
  constructor() {
8
5
  this.dialect = 'postgres';
9
6
  }
@@ -12,11 +9,11 @@ class PostgresSerializer {
12
9
  }
13
10
  serialize(ctx, type, o, defFn) {
14
11
  switch (type) {
15
- case builder_1.SerializationType.SELECT_QUERY:
12
+ case SerializationType.SELECT_QUERY:
16
13
  return this._serializeSelect(ctx, o, defFn);
17
- case builder_1.SerializationType.COMPARISON_EXPRESSION:
14
+ case SerializationType.COMPARISON_EXPRESSION:
18
15
  return this._serializeComparison(ctx, o, defFn);
19
- case builder_1.SerializationType.EXTERNAL_PARAMETER:
16
+ case SerializationType.EXTERNAL_PARAMETER:
20
17
  return this._serializeParameter(ctx, o, defFn);
21
18
  default:
22
19
  return undefined;
@@ -37,9 +34,9 @@ class PostgresSerializer {
37
34
  if (!Array.isArray(o.right)) {
38
35
  if (o.right.expression.toLowerCase() === 'null') {
39
36
  if (o.operatorType === 'eq')
40
- return defFn(ctx, { ...o, operatorType: builder_1.OperatorType.is, symbol: 'is' });
37
+ return defFn(ctx, { ...o, operatorType: OperatorType.is, symbol: 'is' });
41
38
  if (o.operatorType === 'ne')
42
- return defFn(ctx, { ...o, operatorType: builder_1.OperatorType.isNot, symbol: 'is not' });
39
+ return defFn(ctx, { ...o, operatorType: OperatorType.isNot, symbol: 'is not' });
43
40
  }
44
41
  }
45
42
  if (o.left.isParam && o.left.isArray && o.left.value != null && !Array.isArray(o.left.value)) {
@@ -55,7 +52,7 @@ class PostgresSerializer {
55
52
  left.expression = 'ANY(' + left.expression + ')';
56
53
  return defFn(ctx, {
57
54
  ...o,
58
- operatorType: builder_1.OperatorType.eq,
55
+ operatorType: OperatorType.eq,
59
56
  symbol: o.operatorType === 'notIn' ? '!=' : '=',
60
57
  left: right,
61
58
  right: left,
@@ -70,7 +67,7 @@ class PostgresSerializer {
70
67
  o.right.expression = 'ANY(' + o.right.expression + ')';
71
68
  return defFn(ctx, {
72
69
  ...o,
73
- operatorType: builder_1.OperatorType.eq,
70
+ operatorType: OperatorType.eq,
74
71
  symbol: o.operatorType === 'notIn' ? '!=' : '=',
75
72
  });
76
73
  }
@@ -84,4 +81,3 @@ class PostgresSerializer {
84
81
  return '$' + ctx.preparedParams.length;
85
82
  }
86
83
  }
87
- exports.PostgresSerializer = PostgresSerializer;
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.15.0",
4
+ "version": "4.16.0",
5
5
  "author": "Panates",
6
6
  "license": "Apache-2.0",
7
7
  "scripts": {
@@ -22,7 +22,7 @@
22
22
  "clean:cover": "rimraf ../../coverage/postgres-dialect"
23
23
  },
24
24
  "peerDependencies": {
25
- "@sqb/builder": "^4.15.0"
25
+ "@sqb/builder": "^4.16.0"
26
26
  },
27
27
  "main": "./cjs/index.js",
28
28
  "module": "./esm/index.js",