@sqb/builder 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/classes.ns.js +38 -41
- package/esm/enums.js +8 -11
- package/esm/extensions.js +1 -5
- package/esm/helpers.js +1 -4
- package/esm/index.js +20 -25
- package/esm/op.initializers.js +46 -78
- package/esm/query/delete-query.js +11 -15
- package/esm/query/insert-query.js +13 -17
- package/esm/query/query.js +10 -15
- package/esm/query/returning-query.js +8 -12
- package/esm/query/select-query.js +28 -32
- package/esm/query/union-query.js +4 -8
- package/esm/query/update-query.js +14 -18
- package/esm/serializable.js +1 -5
- package/esm/serialize-context.js +15 -19
- package/esm/sql-objects/base-field.js +2 -6
- package/esm/sql-objects/case-statement.js +6 -10
- package/esm/sql-objects/coalesce-statement.js +4 -8
- package/esm/sql-objects/count-statement.js +4 -8
- package/esm/sql-objects/expression.js +2 -6
- package/esm/sql-objects/field-expression.js +4 -8
- package/esm/sql-objects/group-column.js +4 -8
- package/esm/sql-objects/join-statement.js +19 -23
- package/esm/sql-objects/lower-statement.js +4 -8
- package/esm/sql-objects/max-statement.js +4 -8
- package/esm/sql-objects/min-statement.js +4 -8
- package/esm/sql-objects/operator.js +2 -6
- package/esm/sql-objects/operators/comp-operator.js +13 -17
- package/esm/sql-objects/operators/logical-operator.js +16 -21
- package/esm/sql-objects/operators/op-and.js +4 -8
- package/esm/sql-objects/operators/op-between.js +4 -8
- package/esm/sql-objects/operators/op-eq.js +4 -8
- package/esm/sql-objects/operators/op-exists.js +6 -10
- package/esm/sql-objects/operators/op-gt.js +4 -8
- package/esm/sql-objects/operators/op-gte.js +4 -8
- package/esm/sql-objects/operators/op-ilike.js +4 -8
- package/esm/sql-objects/operators/op-in.js +6 -10
- package/esm/sql-objects/operators/op-is-not.js +4 -8
- package/esm/sql-objects/operators/op-is.js +4 -8
- package/esm/sql-objects/operators/op-like.js +4 -8
- package/esm/sql-objects/operators/op-lt.js +4 -8
- package/esm/sql-objects/operators/op-lte.js +4 -8
- package/esm/sql-objects/operators/op-ne.js +4 -8
- package/esm/sql-objects/operators/op-not-between.js +4 -8
- package/esm/sql-objects/operators/op-not-exists.js +4 -8
- package/esm/sql-objects/operators/op-not-ilike.js +4 -8
- package/esm/sql-objects/operators/op-not-in.js +4 -8
- package/esm/sql-objects/operators/op-not-like.js +4 -8
- package/esm/sql-objects/operators/op-not.js +5 -9
- package/esm/sql-objects/operators/op-or.js +4 -8
- package/esm/sql-objects/order-column.js +4 -8
- package/esm/sql-objects/param-expression.js +4 -8
- package/esm/sql-objects/raw-statement.js +4 -8
- package/esm/sql-objects/returning-column.js +4 -8
- package/esm/sql-objects/sequence-getter-statement.js +4 -8
- package/esm/sql-objects/string-agg-statement.js +11 -15
- package/esm/sql-objects/table-name.js +4 -8
- package/esm/sql-objects/upper-statement.js +4 -8
- package/esm/sqlobject.initializers.js +101 -131
- package/esm/typeguards.js +59 -80
- package/esm/types.js +1 -2
- package/package.json +1 -1
package/esm/classes.ns.js
CHANGED
|
@@ -1,41 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
tslib_1.__exportStar(require("./sql-objects/order-column.js"), exports);
|
|
40
|
-
tslib_1.__exportStar(require("./sql-objects/raw-statement.js"), exports);
|
|
41
|
-
tslib_1.__exportStar(require("./sql-objects/table-name.js"), exports);
|
|
1
|
+
export * from './query/delete-query.js';
|
|
2
|
+
export * from './query/insert-query.js';
|
|
3
|
+
export * from './query/query.js';
|
|
4
|
+
export * from './query/returning-query.js';
|
|
5
|
+
export * from './query/select-query.js';
|
|
6
|
+
export * from './query/update-query.js';
|
|
7
|
+
export * from './sql-objects/base-field.js';
|
|
8
|
+
export * from './sql-objects/case-statement.js';
|
|
9
|
+
export * from './sql-objects/count-statement.js';
|
|
10
|
+
export * from './sql-objects/field-expression.js';
|
|
11
|
+
export * from './sql-objects/group-column.js';
|
|
12
|
+
export * from './sql-objects/join-statement.js';
|
|
13
|
+
export * from './sql-objects/operator.js';
|
|
14
|
+
export * from './sql-objects/operators/comp-operator.js';
|
|
15
|
+
export * from './sql-objects/operators/logical-operator.js';
|
|
16
|
+
export * from './sql-objects/operators/op-and.js';
|
|
17
|
+
export * from './sql-objects/operators/op-between.js';
|
|
18
|
+
export * from './sql-objects/operators/op-eq.js';
|
|
19
|
+
export * from './sql-objects/operators/op-exists.js';
|
|
20
|
+
export * from './sql-objects/operators/op-gt.js';
|
|
21
|
+
export * from './sql-objects/operators/op-gte.js';
|
|
22
|
+
export * from './sql-objects/operators/op-ilike.js';
|
|
23
|
+
export * from './sql-objects/operators/op-in.js';
|
|
24
|
+
export * from './sql-objects/operators/op-is.js';
|
|
25
|
+
export * from './sql-objects/operators/op-is-not.js';
|
|
26
|
+
export * from './sql-objects/operators/op-like.js';
|
|
27
|
+
export * from './sql-objects/operators/op-lt.js';
|
|
28
|
+
export * from './sql-objects/operators/op-lte.js';
|
|
29
|
+
export * from './sql-objects/operators/op-ne.js';
|
|
30
|
+
export * from './sql-objects/operators/op-not-between.js';
|
|
31
|
+
export * from './sql-objects/operators/op-not-exists.js';
|
|
32
|
+
export * from './sql-objects/operators/op-not-ilike.js';
|
|
33
|
+
export * from './sql-objects/operators/op-not-in.js';
|
|
34
|
+
export * from './sql-objects/operators/op-not-like.js';
|
|
35
|
+
export * from './sql-objects/operators/op-or.js';
|
|
36
|
+
export * from './sql-objects/order-column.js';
|
|
37
|
+
export * from './sql-objects/raw-statement.js';
|
|
38
|
+
export * from './sql-objects/table-name.js';
|
package/esm/enums.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataType = exports.OperatorType = exports.SerializationType = exports.JoinType = void 0;
|
|
4
|
-
var JoinType;
|
|
1
|
+
export var JoinType;
|
|
5
2
|
(function (JoinType) {
|
|
6
3
|
JoinType["INNER"] = "inner";
|
|
7
4
|
JoinType["LEFT"] = "left";
|
|
@@ -11,8 +8,8 @@ var JoinType;
|
|
|
11
8
|
JoinType["OUTER"] = "outer";
|
|
12
9
|
JoinType["FULL_OUTER"] = "full outer";
|
|
13
10
|
JoinType["CROSS"] = "cross";
|
|
14
|
-
})(JoinType || (
|
|
15
|
-
var SerializationType;
|
|
11
|
+
})(JoinType || (JoinType = {}));
|
|
12
|
+
export var SerializationType;
|
|
16
13
|
(function (SerializationType) {
|
|
17
14
|
SerializationType["SELECT_QUERY"] = "select_query";
|
|
18
15
|
SerializationType["SELECT_QUERY_COLUMNS"] = "select_query.columns";
|
|
@@ -55,8 +52,8 @@ var SerializationType;
|
|
|
55
52
|
SerializationType["ARRAY"] = "array";
|
|
56
53
|
SerializationType["SEQUENCE_GETTER_STATEMENT"] = "sequence_getter_statement";
|
|
57
54
|
SerializationType["STRINGAGG_STATEMENT"] = "String_agg_statement";
|
|
58
|
-
})(SerializationType || (
|
|
59
|
-
var OperatorType;
|
|
55
|
+
})(SerializationType || (SerializationType = {}));
|
|
56
|
+
export var OperatorType;
|
|
60
57
|
(function (OperatorType) {
|
|
61
58
|
OperatorType["and"] = "and";
|
|
62
59
|
OperatorType["or"] = "or";
|
|
@@ -79,8 +76,8 @@ var OperatorType;
|
|
|
79
76
|
OperatorType["exists"] = "exists";
|
|
80
77
|
OperatorType["notExists"] = "notExists";
|
|
81
78
|
OperatorType["not"] = "not";
|
|
82
|
-
})(OperatorType || (
|
|
83
|
-
var DataType;
|
|
79
|
+
})(OperatorType || (OperatorType = {}));
|
|
80
|
+
export var DataType;
|
|
84
81
|
(function (DataType) {
|
|
85
82
|
DataType["BOOL"] = "BOOL";
|
|
86
83
|
DataType["CHAR"] = "CHAR";
|
|
@@ -99,4 +96,4 @@ var DataType;
|
|
|
99
96
|
DataType["TEXT"] = "TEXT";
|
|
100
97
|
DataType["GUID"] = "GUID";
|
|
101
98
|
DataType["JSON"] = "JSON";
|
|
102
|
-
})(DataType || (
|
|
99
|
+
})(DataType || (DataType = {}));
|
package/esm/extensions.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SerializerRegistry = void 0;
|
|
4
|
-
class SerializerRegistry {
|
|
1
|
+
export class SerializerRegistry {
|
|
5
2
|
static get size() {
|
|
6
3
|
return this.serializers.length;
|
|
7
4
|
}
|
|
@@ -34,5 +31,4 @@ class SerializerRegistry {
|
|
|
34
31
|
return !!this.serializers.find(x => x === extension);
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
exports.SerializerRegistry = SerializerRegistry;
|
|
38
34
|
SerializerRegistry.serializers = [];
|
package/esm/helpers.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printArray = printArray;
|
|
4
1
|
/**
|
|
5
2
|
* Prints array with line feeding
|
|
6
3
|
*/
|
|
7
|
-
function printArray(arr, sep, lfLen) {
|
|
4
|
+
export function printArray(arr, sep, lfLen) {
|
|
8
5
|
let out = '';
|
|
9
6
|
let line = '';
|
|
10
7
|
let k = 0;
|
package/esm/index.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
tslib_1.__exportStar(require("./sql-objects/operators/comp-operator.js"), exports);
|
|
22
|
-
tslib_1.__exportStar(require("./sql-objects/operators/logical-operator.js"), exports);
|
|
23
|
-
tslib_1.__exportStar(require("./sqlobject.initializers.js"), exports);
|
|
24
|
-
tslib_1.__exportStar(require("./typeguards.js"), exports);
|
|
25
|
-
tslib_1.__exportStar(require("./types.js"), exports);
|
|
1
|
+
export * as classes from './classes.ns.js';
|
|
2
|
+
export * from './enums.js';
|
|
3
|
+
export * from './extensions.js';
|
|
4
|
+
export * from './helpers.js';
|
|
5
|
+
export * from './op.initializers.js';
|
|
6
|
+
export { op } from './op.initializers.js';
|
|
7
|
+
export * from './query/delete-query.js';
|
|
8
|
+
export * from './query/insert-query.js';
|
|
9
|
+
export * from './query/query.js';
|
|
10
|
+
export * from './query/select-query.js';
|
|
11
|
+
export * from './query/update-query.js';
|
|
12
|
+
export * from './serializable.js';
|
|
13
|
+
export * from './serialize-context.js';
|
|
14
|
+
export * from './sql-objects/join-statement.js';
|
|
15
|
+
export * from './sql-objects/operator.js';
|
|
16
|
+
export * from './sql-objects/operators/comp-operator.js';
|
|
17
|
+
export * from './sql-objects/operators/logical-operator.js';
|
|
18
|
+
export * from './sqlobject.initializers.js';
|
|
19
|
+
export * from './typeguards.js';
|
|
20
|
+
export * from './types.js';
|
package/esm/op.initializers.js
CHANGED
|
@@ -1,122 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
exports.NotEqual = Ne;
|
|
24
|
-
exports.Nilike = NotILike;
|
|
25
|
-
exports.NotILike = NotILike;
|
|
26
|
-
exports.Nin = NotIn;
|
|
27
|
-
exports.NotIn = NotIn;
|
|
28
|
-
exports.NLike = NotLike;
|
|
29
|
-
exports.NotLike = NotLike;
|
|
30
|
-
exports.Not = Not;
|
|
31
|
-
exports.NotBetween = NotBetween;
|
|
32
|
-
exports.NotExists = NotExists;
|
|
33
|
-
exports.Or = Or;
|
|
34
|
-
const logical_operator_js_1 = require("./sql-objects/operators/logical-operator.js");
|
|
35
|
-
const op_and_js_1 = require("./sql-objects/operators/op-and.js");
|
|
36
|
-
const op_between_js_1 = require("./sql-objects/operators/op-between.js");
|
|
37
|
-
const op_eq_js_1 = require("./sql-objects/operators/op-eq.js");
|
|
38
|
-
const op_exists_js_1 = require("./sql-objects/operators/op-exists.js");
|
|
39
|
-
const op_gt_js_1 = require("./sql-objects/operators/op-gt.js");
|
|
40
|
-
const op_gte_js_1 = require("./sql-objects/operators/op-gte.js");
|
|
41
|
-
const op_ilike_js_1 = require("./sql-objects/operators/op-ilike.js");
|
|
42
|
-
const op_in_js_1 = require("./sql-objects/operators/op-in.js");
|
|
43
|
-
const op_is_js_1 = require("./sql-objects/operators/op-is.js");
|
|
44
|
-
const op_is_not_js_1 = require("./sql-objects/operators/op-is-not.js");
|
|
45
|
-
const op_like_js_1 = require("./sql-objects/operators/op-like.js");
|
|
46
|
-
const op_lt_js_1 = require("./sql-objects/operators/op-lt.js");
|
|
47
|
-
const op_lte_js_1 = require("./sql-objects/operators/op-lte.js");
|
|
48
|
-
const op_ne_js_1 = require("./sql-objects/operators/op-ne.js");
|
|
49
|
-
const op_not_js_1 = require("./sql-objects/operators/op-not.js");
|
|
50
|
-
const op_not_between_js_1 = require("./sql-objects/operators/op-not-between.js");
|
|
51
|
-
const op_not_exists_js_1 = require("./sql-objects/operators/op-not-exists.js");
|
|
52
|
-
const op_not_ilike_js_1 = require("./sql-objects/operators/op-not-ilike.js");
|
|
53
|
-
const op_not_in_js_1 = require("./sql-objects/operators/op-not-in.js");
|
|
54
|
-
const op_not_like_js_1 = require("./sql-objects/operators/op-not-like.js");
|
|
55
|
-
const op_or_js_1 = require("./sql-objects/operators/op-or.js");
|
|
1
|
+
import { WrapOps } from './sql-objects/operators/logical-operator.js';
|
|
2
|
+
import { OpAnd } from './sql-objects/operators/op-and.js';
|
|
3
|
+
import { OpBetween } from './sql-objects/operators/op-between.js';
|
|
4
|
+
import { OpEq } from './sql-objects/operators/op-eq.js';
|
|
5
|
+
import { OpExists } from './sql-objects/operators/op-exists.js';
|
|
6
|
+
import { OpGt } from './sql-objects/operators/op-gt.js';
|
|
7
|
+
import { OpGte } from './sql-objects/operators/op-gte.js';
|
|
8
|
+
import { OpILike } from './sql-objects/operators/op-ilike.js';
|
|
9
|
+
import { OpIn } from './sql-objects/operators/op-in.js';
|
|
10
|
+
import { OpIs } from './sql-objects/operators/op-is.js';
|
|
11
|
+
import { OpIsNot } from './sql-objects/operators/op-is-not.js';
|
|
12
|
+
import { OpLike } from './sql-objects/operators/op-like.js';
|
|
13
|
+
import { OpLt } from './sql-objects/operators/op-lt.js';
|
|
14
|
+
import { OpLte } from './sql-objects/operators/op-lte.js';
|
|
15
|
+
import { OpNe } from './sql-objects/operators/op-ne.js';
|
|
16
|
+
import { OpNot } from './sql-objects/operators/op-not.js';
|
|
17
|
+
import { OpNotBetween } from './sql-objects/operators/op-not-between.js';
|
|
18
|
+
import { OpNotExists } from './sql-objects/operators/op-not-exists.js';
|
|
19
|
+
import { OpNotILike } from './sql-objects/operators/op-not-ilike.js';
|
|
20
|
+
import { OpNotIn } from './sql-objects/operators/op-not-in.js';
|
|
21
|
+
import { OpNotLike } from './sql-objects/operators/op-not-like.js';
|
|
22
|
+
import { OpOr } from './sql-objects/operators/op-or.js';
|
|
56
23
|
function And(...args) {
|
|
57
|
-
return new
|
|
24
|
+
return new OpAnd(...args);
|
|
58
25
|
}
|
|
59
26
|
function Or(...args) {
|
|
60
|
-
return new
|
|
27
|
+
return new OpOr(...args);
|
|
61
28
|
}
|
|
62
29
|
function Eq(expression, value) {
|
|
63
|
-
return new
|
|
30
|
+
return new OpEq(expression, value);
|
|
64
31
|
}
|
|
65
32
|
function Ne(expression, value) {
|
|
66
|
-
return new
|
|
33
|
+
return new OpNe(expression, value);
|
|
67
34
|
}
|
|
68
35
|
function Gt(expression, value) {
|
|
69
|
-
return new
|
|
36
|
+
return new OpGt(expression, value);
|
|
70
37
|
}
|
|
71
38
|
function Gte(expression, value) {
|
|
72
|
-
return new
|
|
39
|
+
return new OpGte(expression, value);
|
|
73
40
|
}
|
|
74
41
|
function Lt(expression, value) {
|
|
75
|
-
return new
|
|
42
|
+
return new OpLt(expression, value);
|
|
76
43
|
}
|
|
77
44
|
function Lte(expression, value) {
|
|
78
|
-
return new
|
|
45
|
+
return new OpLte(expression, value);
|
|
79
46
|
}
|
|
80
47
|
function Between(expression, value1, value2) {
|
|
81
48
|
const values = Array.isArray(value1) ? value1 : [value1, value2];
|
|
82
|
-
return new
|
|
49
|
+
return new OpBetween(expression, values);
|
|
83
50
|
}
|
|
84
51
|
function NotBetween(expression, value1, value2) {
|
|
85
52
|
const values = Array.isArray(value1) ? value1 : [value1, value2];
|
|
86
|
-
return new
|
|
53
|
+
return new OpNotBetween(expression, values);
|
|
87
54
|
}
|
|
88
55
|
function In(expression, value) {
|
|
89
|
-
return new
|
|
56
|
+
return new OpIn(expression, value);
|
|
90
57
|
}
|
|
91
58
|
function NotIn(expression, value) {
|
|
92
|
-
return new
|
|
59
|
+
return new OpNotIn(expression, value);
|
|
93
60
|
}
|
|
94
61
|
function Like(expression, value) {
|
|
95
|
-
return new
|
|
62
|
+
return new OpLike(expression, value);
|
|
96
63
|
}
|
|
97
64
|
function NotLike(expression, value) {
|
|
98
|
-
return new
|
|
65
|
+
return new OpNotLike(expression, value);
|
|
99
66
|
}
|
|
100
67
|
function Ilike(expression, value) {
|
|
101
|
-
return new
|
|
68
|
+
return new OpILike(expression, value);
|
|
102
69
|
}
|
|
103
70
|
function NotILike(expression, value) {
|
|
104
|
-
return new
|
|
71
|
+
return new OpNotILike(expression, value);
|
|
105
72
|
}
|
|
106
73
|
function Is(expression, value) {
|
|
107
|
-
return new
|
|
74
|
+
return new OpIs(expression, value);
|
|
108
75
|
}
|
|
109
76
|
function IsNot(expression, value) {
|
|
110
|
-
return new
|
|
77
|
+
return new OpIsNot(expression, value);
|
|
111
78
|
}
|
|
112
79
|
function Exists(expression) {
|
|
113
|
-
return new
|
|
80
|
+
return new OpExists(expression);
|
|
114
81
|
}
|
|
115
82
|
function NotExists(expression) {
|
|
116
|
-
return new
|
|
83
|
+
return new OpNotExists(expression);
|
|
117
84
|
}
|
|
118
85
|
function Not(expression) {
|
|
119
|
-
return new
|
|
86
|
+
return new OpNot(expression);
|
|
120
87
|
}
|
|
121
88
|
const op = {
|
|
122
89
|
and: And,
|
|
@@ -159,5 +126,6 @@ const op = {
|
|
|
159
126
|
notExists: NotExists,
|
|
160
127
|
'!exists': NotExists,
|
|
161
128
|
};
|
|
162
|
-
|
|
163
|
-
|
|
129
|
+
Object.assign(WrapOps, op);
|
|
130
|
+
export { op };
|
|
131
|
+
export { And, Between, Eq, Eq as Equal, Exists, Gte as GreaterAnEqualTo, Gt as GreaterThan, Gt, Gte, Ilike, In, Is, IsNot, Like, Lte as LowerAndEqualTo, Lt as LowerThan, Lt, Lte, Ne, NotILike as Nilike, NotIn as Nin, NotLike as NLike, Not, NotBetween, Ne as NotEqual, NotExists, NotILike, NotIn, NotLike, Or, };
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const typeguards_js_1 = require("../typeguards.js");
|
|
8
|
-
const query_js_1 = require("./query.js");
|
|
9
|
-
class DeleteQuery extends query_js_1.Query {
|
|
1
|
+
import { SerializationType } from '../enums.js';
|
|
2
|
+
import { OpAnd } from '../sql-objects/operators/op-and.js';
|
|
3
|
+
import { TableName } from '../sql-objects/table-name.js';
|
|
4
|
+
import { isRawStatement } from '../typeguards.js';
|
|
5
|
+
import { Query } from './query.js';
|
|
6
|
+
export class DeleteQuery extends Query {
|
|
10
7
|
constructor(tableName) {
|
|
11
8
|
super();
|
|
12
|
-
if (!tableName || !(typeof tableName === 'string' ||
|
|
9
|
+
if (!tableName || !(typeof tableName === 'string' || isRawStatement(tableName))) {
|
|
13
10
|
throw new TypeError('String or Raw instance required as first argument (tableName) for UpdateQuery');
|
|
14
11
|
}
|
|
15
|
-
this._table = typeof tableName === 'string' ? new
|
|
12
|
+
this._table = typeof tableName === 'string' ? new TableName(tableName) : tableName;
|
|
16
13
|
}
|
|
17
14
|
get _type() {
|
|
18
|
-
return
|
|
15
|
+
return SerializationType.DELETE_QUERY;
|
|
19
16
|
}
|
|
20
17
|
/**
|
|
21
18
|
* Defines "where" part of query
|
|
22
19
|
*/
|
|
23
20
|
where(...operator) {
|
|
24
|
-
this._where = this._where || new
|
|
21
|
+
this._where = this._where || new OpAnd();
|
|
25
22
|
this._where.add(...operator);
|
|
26
23
|
return this;
|
|
27
24
|
}
|
|
@@ -45,9 +42,8 @@ class DeleteQuery extends query_js_1.Query {
|
|
|
45
42
|
if (!this._where)
|
|
46
43
|
return '';
|
|
47
44
|
const s = this._where._serialize(ctx);
|
|
48
|
-
return ctx.serialize(
|
|
45
|
+
return ctx.serialize(SerializationType.CONDITIONS_BLOCK, s, () =>
|
|
49
46
|
/* istanbul ignore next */
|
|
50
47
|
s ? 'where ' + s : '');
|
|
51
48
|
}
|
|
52
49
|
}
|
|
53
|
-
exports.DeleteQuery = DeleteQuery;
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const typeguards_js_1 = require("../typeguards.js");
|
|
8
|
-
const returning_query_js_1 = require("./returning-query.js");
|
|
9
|
-
class InsertQuery extends returning_query_js_1.ReturningQuery {
|
|
1
|
+
import { SerializationType } from '../enums.js';
|
|
2
|
+
import { printArray } from '../helpers.js';
|
|
3
|
+
import { TableName } from '../sql-objects/table-name.js';
|
|
4
|
+
import { isRawStatement, isSelectQuery, isSerializable } from '../typeguards.js';
|
|
5
|
+
import { ReturningQuery } from './returning-query.js';
|
|
6
|
+
export class InsertQuery extends ReturningQuery {
|
|
10
7
|
constructor(tableName, input) {
|
|
11
8
|
super();
|
|
12
|
-
if (!tableName || !(typeof tableName === 'string' ||
|
|
9
|
+
if (!tableName || !(typeof tableName === 'string' || isRawStatement(tableName))) {
|
|
13
10
|
throw new TypeError('String or Raw instance required as first argument (tableName) for InsertQuery');
|
|
14
11
|
}
|
|
15
12
|
if (!input || !((typeof input === 'object' && !Array.isArray(input)) || input.isSelect)) {
|
|
16
13
|
throw new TypeError('Object or SelectQuery instance required as second argument (input) for InsertQuery');
|
|
17
14
|
}
|
|
18
|
-
this._table = typeof tableName === 'string' ? new
|
|
15
|
+
this._table = typeof tableName === 'string' ? new TableName(tableName) : tableName;
|
|
19
16
|
this._input = input;
|
|
20
17
|
}
|
|
21
18
|
get _type() {
|
|
22
|
-
return
|
|
19
|
+
return SerializationType.INSERT_QUERY;
|
|
23
20
|
}
|
|
24
21
|
/**
|
|
25
22
|
* Performs serialization
|
|
@@ -41,7 +38,7 @@ class InsertQuery extends returning_query_js_1.ReturningQuery {
|
|
|
41
38
|
*/
|
|
42
39
|
__serializeColumns(ctx) {
|
|
43
40
|
let arr;
|
|
44
|
-
if (
|
|
41
|
+
if (isSelectQuery(this._input)) {
|
|
45
42
|
arr = [];
|
|
46
43
|
const cols = this._input._columns;
|
|
47
44
|
if (cols) {
|
|
@@ -55,13 +52,13 @@ class InsertQuery extends returning_query_js_1.ReturningQuery {
|
|
|
55
52
|
}
|
|
56
53
|
else
|
|
57
54
|
arr = Object.keys(this._input);
|
|
58
|
-
return ctx.serialize(
|
|
55
|
+
return ctx.serialize(SerializationType.INSERT_QUERY_COLUMNS, arr, () => printArray(arr));
|
|
59
56
|
}
|
|
60
57
|
/**
|
|
61
58
|
*
|
|
62
59
|
*/
|
|
63
60
|
__serializeValues(ctx) {
|
|
64
|
-
if (
|
|
61
|
+
if (isSerializable(this._input))
|
|
65
62
|
return this._input._serialize(ctx);
|
|
66
63
|
const arr = [];
|
|
67
64
|
const allValues = this._input;
|
|
@@ -69,7 +66,6 @@ class InsertQuery extends returning_query_js_1.ReturningQuery {
|
|
|
69
66
|
const s = ctx.anyToSQL(allValues[n]) || 'null';
|
|
70
67
|
arr.push(s);
|
|
71
68
|
}
|
|
72
|
-
return ctx.serialize(
|
|
69
|
+
return ctx.serialize(SerializationType.INSERT_QUERY_VALUES, arr, () => printArray(arr));
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
|
-
exports.InsertQuery = InsertQuery;
|
package/esm/query/query.js
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
|
|
8
|
-
const serializable_js_1 = require("../serializable.js");
|
|
9
|
-
const serialize_context_js_1 = require("../serialize-context.js");
|
|
10
|
-
class Query extends serializable_js_1.Serializable {
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import flattenText from 'putil-flattentext';
|
|
3
|
+
import merge from 'putil-merge';
|
|
4
|
+
import { Serializable } from '../serializable.js';
|
|
5
|
+
import { SerializeContext } from '../serialize-context.js';
|
|
6
|
+
export class Query extends Serializable {
|
|
11
7
|
constructor() {
|
|
12
8
|
super();
|
|
13
|
-
|
|
9
|
+
EventEmitter.call(this);
|
|
14
10
|
}
|
|
15
11
|
/**
|
|
16
12
|
* Generates Sql script
|
|
17
13
|
*/
|
|
18
14
|
generate(options) {
|
|
19
|
-
const ctx = new
|
|
15
|
+
const ctx = new SerializeContext(options);
|
|
20
16
|
if (this._params)
|
|
21
17
|
ctx.params = { ...ctx.params, ...this._params };
|
|
22
18
|
ctx.serializeHooks = this.listeners('serialize');
|
|
23
19
|
/* generate output */
|
|
24
20
|
const sql = this._serialize(ctx);
|
|
25
21
|
return {
|
|
26
|
-
sql: (
|
|
22
|
+
sql: flattenText(sql, { noWrap: !ctx.prettyPrint }),
|
|
27
23
|
params: ctx.preparedParams,
|
|
28
24
|
paramOptions: ctx.paramOptions,
|
|
29
25
|
returningFields: ctx.returningFields,
|
|
@@ -36,5 +32,4 @@ class Query extends serializable_js_1.Serializable {
|
|
|
36
32
|
return this;
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
|
-
|
|
40
|
-
(0, putil_merge_1.default)(Query.prototype, events_1.EventEmitter.prototype, { descriptor: true });
|
|
35
|
+
merge(Query.prototype, EventEmitter.prototype, { descriptor: true });
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const returning_column_js_1 = require("../sql-objects/returning-column.js");
|
|
7
|
-
const query_js_1 = require("./query.js");
|
|
8
|
-
class ReturningQuery extends query_js_1.Query {
|
|
1
|
+
import { SerializationType } from '../enums.js';
|
|
2
|
+
import { printArray } from '../helpers.js';
|
|
3
|
+
import { ReturningColumn } from '../sql-objects/returning-column.js';
|
|
4
|
+
import { Query } from './query.js';
|
|
5
|
+
export class ReturningQuery extends Query {
|
|
9
6
|
/**
|
|
10
7
|
*
|
|
11
8
|
*/
|
|
@@ -16,7 +13,7 @@ class ReturningQuery extends query_js_1.Query {
|
|
|
16
13
|
this._returningColumns = columns.length
|
|
17
14
|
? columns.reduce((a, v) => {
|
|
18
15
|
if (v)
|
|
19
|
-
a.push(new
|
|
16
|
+
a.push(new ReturningColumn(v));
|
|
20
17
|
return a;
|
|
21
18
|
}, [])
|
|
22
19
|
: undefined;
|
|
@@ -36,10 +33,9 @@ class ReturningQuery extends query_js_1.Query {
|
|
|
36
33
|
if (s)
|
|
37
34
|
arr.push(s);
|
|
38
35
|
}
|
|
39
|
-
return ctx.serialize(
|
|
40
|
-
const s =
|
|
36
|
+
return ctx.serialize(SerializationType.RETURNING_BLOCK, arr, () => {
|
|
37
|
+
const s = printArray(arr);
|
|
41
38
|
return s ? 'returning ' + s : '';
|
|
42
39
|
});
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
|
-
exports.ReturningQuery = ReturningQuery;
|