@sqb/builder 4.12.1 → 4.13.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/cjs/classes.ns.js +24 -24
- package/cjs/extensions.js +34 -12
- package/cjs/helpers.js +1 -2
- package/cjs/index.js +14 -16
- package/cjs/op.initializers.js +31 -31
- package/cjs/query/delete-query.js +5 -5
- package/cjs/query/insert-query.js +4 -2
- package/cjs/query/select-query.js +14 -12
- package/cjs/query/update-query.js +7 -6
- package/cjs/serialize-context.js +2 -2
- package/cjs/sql-objects/case-statement.js +2 -1
- package/cjs/sql-objects/group-column.js +3 -5
- package/cjs/sql-objects/join-statement.js +3 -2
- package/cjs/sql-objects/operators/comp-operator.js +6 -8
- package/cjs/sql-objects/operators/op-exists.js +2 -1
- package/cjs/sql-objects/operators/op-not.js +1 -3
- package/cjs/sql-objects/order-column.js +4 -6
- package/cjs/sql-objects/returning-column.js +1 -3
- package/cjs/sql-objects/string-agg-statement.js +2 -1
- package/cjs/sqlobject.initializers.js +28 -29
- package/cjs/typeguards.js +19 -20
- package/esm/classes.ns.js +24 -24
- package/esm/extensions.js +32 -9
- package/esm/index.js +12 -12
- package/esm/op.initializers.js +1 -1
- package/esm/query/delete-query.js +5 -5
- package/esm/query/insert-query.js +4 -2
- package/esm/query/select-query.js +14 -12
- package/esm/query/update-query.js +7 -6
- package/esm/serialize-context.js +3 -3
- package/esm/sql-objects/case-statement.js +2 -1
- package/esm/sql-objects/group-column.js +3 -5
- package/esm/sql-objects/join-statement.js +3 -2
- package/esm/sql-objects/operators/comp-operator.js +6 -8
- package/esm/sql-objects/operators/op-exists.js +2 -1
- package/esm/sql-objects/operators/op-not.js +1 -3
- package/esm/sql-objects/order-column.js +4 -6
- package/esm/sql-objects/returning-column.js +1 -3
- package/esm/sql-objects/string-agg-statement.js +2 -1
- package/package.json +1 -1
- package/types/classes.ns.d.ts +24 -24
- package/types/extensions.d.ts +12 -3
- package/types/index.d.ts +12 -12
- package/types/op.initializers.d.ts +1 -1
- package/types/query/query.d.ts +0 -1
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Raw = Raw;
|
|
4
|
+
exports.Select = Select;
|
|
5
|
+
exports.Insert = Insert;
|
|
6
|
+
exports.Update = Update;
|
|
7
|
+
exports.Delete = Delete;
|
|
8
|
+
exports.Union = Union;
|
|
9
|
+
exports.UnionAll = UnionAll;
|
|
10
|
+
exports.Join = Join;
|
|
11
|
+
exports.InnerJoin = InnerJoin;
|
|
12
|
+
exports.LeftJoin = LeftJoin;
|
|
13
|
+
exports.LeftOuterJoin = LeftOuterJoin;
|
|
14
|
+
exports.RightJoin = RightJoin;
|
|
15
|
+
exports.RightOuterJoin = RightOuterJoin;
|
|
16
|
+
exports.OuterJoin = OuterJoin;
|
|
17
|
+
exports.FullOuterJoin = FullOuterJoin;
|
|
18
|
+
exports.CrossJoin = CrossJoin;
|
|
19
|
+
exports.Case = Case;
|
|
20
|
+
exports.Coalesce = Coalesce;
|
|
21
|
+
exports.Lower = Lower;
|
|
22
|
+
exports.Upper = Upper;
|
|
23
|
+
exports.Min = Min;
|
|
24
|
+
exports.Max = Max;
|
|
25
|
+
exports.StringAGG = StringAGG;
|
|
26
|
+
exports.Count = Count;
|
|
27
|
+
exports.SequenceNext = SequenceNext;
|
|
28
|
+
exports.SequenceCurr = SequenceCurr;
|
|
29
|
+
exports.Param = Param;
|
|
30
|
+
exports.Field = Field;
|
|
4
31
|
const enums_js_1 = require("./enums.js");
|
|
5
32
|
const delete_query_js_1 = require("./query/delete-query.js");
|
|
6
33
|
const insert_query_js_1 = require("./query/insert-query.js");
|
|
@@ -23,107 +50,81 @@ const upper_statement_js_1 = require("./sql-objects/upper-statement.js");
|
|
|
23
50
|
function Raw(text) {
|
|
24
51
|
return new raw_statement_js_1.RawStatement(text);
|
|
25
52
|
}
|
|
26
|
-
exports.Raw = Raw;
|
|
27
53
|
function Select(...column) {
|
|
28
54
|
return new select_query_js_1.SelectQuery(...column);
|
|
29
55
|
}
|
|
30
|
-
exports.Select = Select;
|
|
31
56
|
function Insert(tableName, input) {
|
|
32
57
|
return new insert_query_js_1.InsertQuery(tableName, input);
|
|
33
58
|
}
|
|
34
|
-
exports.Insert = Insert;
|
|
35
59
|
function Update(tableName, input) {
|
|
36
60
|
return new update_query_js_1.UpdateQuery(tableName, input);
|
|
37
61
|
}
|
|
38
|
-
exports.Update = Update;
|
|
39
62
|
function Delete(tableName) {
|
|
40
63
|
return new delete_query_js_1.DeleteQuery(tableName);
|
|
41
64
|
}
|
|
42
|
-
exports.Delete = Delete;
|
|
43
65
|
function Union(...queries) {
|
|
44
66
|
return new union_query_js_1.UnionQuery(queries);
|
|
45
67
|
}
|
|
46
|
-
exports.Union = Union;
|
|
47
68
|
function UnionAll(...queries) {
|
|
48
69
|
return new union_query_js_1.UnionQuery(queries, 'all');
|
|
49
70
|
}
|
|
50
|
-
exports.UnionAll = UnionAll;
|
|
51
71
|
function Join(table) {
|
|
52
72
|
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.INNER, table);
|
|
53
73
|
}
|
|
54
|
-
exports.Join = Join;
|
|
55
74
|
function InnerJoin(table) {
|
|
56
75
|
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.INNER, table);
|
|
57
76
|
}
|
|
58
|
-
exports.InnerJoin = InnerJoin;
|
|
59
77
|
function LeftJoin(table) {
|
|
60
78
|
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.LEFT, table);
|
|
61
79
|
}
|
|
62
|
-
exports.LeftJoin = LeftJoin;
|
|
63
80
|
function LeftOuterJoin(table) {
|
|
64
81
|
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.LEFT_OUTER, table);
|
|
65
82
|
}
|
|
66
|
-
exports.LeftOuterJoin = LeftOuterJoin;
|
|
67
83
|
function RightJoin(table) {
|
|
68
84
|
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.RIGHT, table);
|
|
69
85
|
}
|
|
70
|
-
exports.RightJoin = RightJoin;
|
|
71
86
|
function RightOuterJoin(table) {
|
|
72
87
|
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.RIGHT_OUTER, table);
|
|
73
88
|
}
|
|
74
|
-
exports.RightOuterJoin = RightOuterJoin;
|
|
75
89
|
function OuterJoin(table) {
|
|
76
90
|
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.OUTER, table);
|
|
77
91
|
}
|
|
78
|
-
exports.OuterJoin = OuterJoin;
|
|
79
92
|
function FullOuterJoin(table) {
|
|
80
93
|
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.FULL_OUTER, table);
|
|
81
94
|
}
|
|
82
|
-
exports.FullOuterJoin = FullOuterJoin;
|
|
83
95
|
function CrossJoin(table) {
|
|
84
96
|
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.CROSS, table);
|
|
85
97
|
}
|
|
86
|
-
exports.CrossJoin = CrossJoin;
|
|
87
98
|
function Case() {
|
|
88
99
|
return new case_statement_js_1.CaseStatement();
|
|
89
100
|
}
|
|
90
|
-
exports.Case = Case;
|
|
91
101
|
function Coalesce(...expressions) {
|
|
92
102
|
return new coalesce_statement_js_1.CoalesceStatement(...expressions);
|
|
93
103
|
}
|
|
94
|
-
exports.Coalesce = Coalesce;
|
|
95
104
|
function Lower(expression) {
|
|
96
105
|
return new lower_statement_js_1.LowerStatement(expression);
|
|
97
106
|
}
|
|
98
|
-
exports.Lower = Lower;
|
|
99
107
|
function Upper(expression) {
|
|
100
108
|
return new upper_statement_js_1.UpperStatement(expression);
|
|
101
109
|
}
|
|
102
|
-
exports.Upper = Upper;
|
|
103
110
|
function Min(expression) {
|
|
104
111
|
return new min_statement_js_1.MinStatement(expression);
|
|
105
112
|
}
|
|
106
|
-
exports.Min = Min;
|
|
107
113
|
function Max(expression) {
|
|
108
114
|
return new max_statement_js_1.MaxStatement(expression);
|
|
109
115
|
}
|
|
110
|
-
exports.Max = Max;
|
|
111
116
|
function StringAGG(field) {
|
|
112
117
|
return new string_agg_statement_js_1.StringAGGStatement(field);
|
|
113
118
|
}
|
|
114
|
-
exports.StringAGG = StringAGG;
|
|
115
119
|
function Count() {
|
|
116
120
|
return new count_statement_js_1.CountStatement();
|
|
117
121
|
}
|
|
118
|
-
exports.Count = Count;
|
|
119
122
|
function SequenceNext(expression) {
|
|
120
123
|
return new sequence_getter_statement_js_1.SequenceGetterStatement(expression, true);
|
|
121
124
|
}
|
|
122
|
-
exports.SequenceNext = SequenceNext;
|
|
123
125
|
function SequenceCurr(expression) {
|
|
124
126
|
return new sequence_getter_statement_js_1.SequenceGetterStatement(expression, false);
|
|
125
127
|
}
|
|
126
|
-
exports.SequenceCurr = SequenceCurr;
|
|
127
128
|
function Param(arg0, arg1, arg2) {
|
|
128
129
|
if (typeof arg0 === 'object')
|
|
129
130
|
return new param_expression_js_1.ParamExpression(arg0);
|
|
@@ -133,10 +134,8 @@ function Param(arg0, arg1, arg2) {
|
|
|
133
134
|
isArray: arg2,
|
|
134
135
|
});
|
|
135
136
|
}
|
|
136
|
-
exports.Param = Param;
|
|
137
137
|
function Field(arg0, arg1, arg2) {
|
|
138
138
|
if (typeof arg0 === 'object')
|
|
139
139
|
return new field_expression_js_1.FieldExpression(arg0);
|
|
140
140
|
return new field_expression_js_1.FieldExpression(arg0, arg1, arg2);
|
|
141
141
|
}
|
|
142
|
-
exports.Field = Field;
|
package/cjs/typeguards.js
CHANGED
|
@@ -1,82 +1,81 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isSerializable = isSerializable;
|
|
4
|
+
exports.isQuery = isQuery;
|
|
5
|
+
exports.isRawStatement = isRawStatement;
|
|
6
|
+
exports.isSelectQuery = isSelectQuery;
|
|
7
|
+
exports.isInsertQuery = isInsertQuery;
|
|
8
|
+
exports.isIUpdateQuery = isIUpdateQuery;
|
|
9
|
+
exports.isDeleteQuery = isDeleteQuery;
|
|
10
|
+
exports.isJoinStatement = isJoinStatement;
|
|
11
|
+
exports.isCaseStatement = isCaseStatement;
|
|
12
|
+
exports.isCountStatement = isCountStatement;
|
|
13
|
+
exports.isParamExpression = isParamExpression;
|
|
14
|
+
exports.isLogicalOperator = isLogicalOperator;
|
|
15
|
+
exports.isCompOperator = isCompOperator;
|
|
16
|
+
exports.isNotOperator = isNotOperator;
|
|
17
|
+
exports.isSelectColumn = isSelectColumn;
|
|
18
|
+
exports.isOrderColumn = isOrderColumn;
|
|
19
|
+
exports.isGroupColumn = isGroupColumn;
|
|
20
|
+
exports.isReturningColumn = isReturningColumn;
|
|
21
|
+
exports.isTableName = isTableName;
|
|
4
22
|
const enums_js_1 = require("./enums.js");
|
|
5
23
|
const query_js_1 = require("./query/query.js");
|
|
6
24
|
const serializable_js_1 = require("./serializable.js");
|
|
7
25
|
function isSerializable(value) {
|
|
8
26
|
return value instanceof serializable_js_1.Serializable;
|
|
9
27
|
}
|
|
10
|
-
exports.isSerializable = isSerializable;
|
|
11
28
|
function isQuery(value) {
|
|
12
29
|
return value instanceof query_js_1.Query;
|
|
13
30
|
}
|
|
14
|
-
exports.isQuery = isQuery;
|
|
15
31
|
function isRawStatement(value) {
|
|
16
32
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.RAW;
|
|
17
33
|
}
|
|
18
|
-
exports.isRawStatement = isRawStatement;
|
|
19
34
|
function isSelectQuery(value) {
|
|
20
35
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.SELECT_QUERY;
|
|
21
36
|
}
|
|
22
|
-
exports.isSelectQuery = isSelectQuery;
|
|
23
37
|
function isInsertQuery(value) {
|
|
24
38
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.INSERT_QUERY;
|
|
25
39
|
}
|
|
26
|
-
exports.isInsertQuery = isInsertQuery;
|
|
27
40
|
function isIUpdateQuery(value) {
|
|
28
41
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.UPDATE_QUERY;
|
|
29
42
|
}
|
|
30
|
-
exports.isIUpdateQuery = isIUpdateQuery;
|
|
31
43
|
function isDeleteQuery(value) {
|
|
32
44
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.DELETE_QUERY;
|
|
33
45
|
}
|
|
34
|
-
exports.isDeleteQuery = isDeleteQuery;
|
|
35
46
|
function isJoinStatement(value) {
|
|
36
47
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.JOIN;
|
|
37
48
|
}
|
|
38
|
-
exports.isJoinStatement = isJoinStatement;
|
|
39
49
|
function isCaseStatement(value) {
|
|
40
50
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.CASE_STATEMENT;
|
|
41
51
|
}
|
|
42
|
-
exports.isCaseStatement = isCaseStatement;
|
|
43
52
|
function isCountStatement(value) {
|
|
44
53
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.COUNT_STATEMENT;
|
|
45
54
|
}
|
|
46
|
-
exports.isCountStatement = isCountStatement;
|
|
47
55
|
function isParamExpression(value) {
|
|
48
56
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.EXTERNAL_PARAMETER;
|
|
49
57
|
}
|
|
50
|
-
exports.isParamExpression = isParamExpression;
|
|
51
58
|
function isLogicalOperator(value) {
|
|
52
59
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.LOGICAL_EXPRESSION;
|
|
53
60
|
}
|
|
54
|
-
exports.isLogicalOperator = isLogicalOperator;
|
|
55
61
|
function isCompOperator(value) {
|
|
56
62
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.COMPARISON_EXPRESSION;
|
|
57
63
|
}
|
|
58
|
-
exports.isCompOperator = isCompOperator;
|
|
59
64
|
function isNotOperator(value) {
|
|
60
65
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.NEGATIVE_EXPRESSION;
|
|
61
66
|
}
|
|
62
|
-
exports.isNotOperator = isNotOperator;
|
|
63
67
|
function isSelectColumn(value) {
|
|
64
68
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.FIELD_NAME;
|
|
65
69
|
}
|
|
66
|
-
exports.isSelectColumn = isSelectColumn;
|
|
67
70
|
function isOrderColumn(value) {
|
|
68
71
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.ORDER_COLUMN;
|
|
69
72
|
}
|
|
70
|
-
exports.isOrderColumn = isOrderColumn;
|
|
71
73
|
function isGroupColumn(value) {
|
|
72
74
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.GROUP_COLUMN;
|
|
73
75
|
}
|
|
74
|
-
exports.isGroupColumn = isGroupColumn;
|
|
75
76
|
function isReturningColumn(value) {
|
|
76
77
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.RETURNING_COLUMN;
|
|
77
78
|
}
|
|
78
|
-
exports.isReturningColumn = isReturningColumn;
|
|
79
79
|
function isTableName(value) {
|
|
80
80
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.TABLE_NAME;
|
|
81
81
|
}
|
|
82
|
-
exports.isTableName = isTableName;
|
package/esm/classes.ns.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
+
export * from './query/delete-query.js';
|
|
2
|
+
export * from './query/insert-query.js';
|
|
1
3
|
export * from './query/query.js';
|
|
2
4
|
export * from './query/returning-query.js';
|
|
3
5
|
export * from './query/select-query.js';
|
|
4
|
-
export * from './query/insert-query.js';
|
|
5
6
|
export * from './query/update-query.js';
|
|
6
|
-
export * from './query/delete-query.js';
|
|
7
|
-
export * from './sql-objects/field-expression.js';
|
|
8
|
-
export * from './sql-objects/table-name.js';
|
|
9
|
-
export * from './sql-objects/order-column.js';
|
|
10
|
-
export * from './sql-objects/group-column.js';
|
|
11
7
|
export * from './sql-objects/base-field.js';
|
|
12
|
-
export * from './sql-objects/operator.js';
|
|
13
8
|
export * from './sql-objects/case-statement.js';
|
|
14
|
-
export * from './sql-objects/join-statement.js';
|
|
15
|
-
export * from './sql-objects/raw-statement.js';
|
|
16
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';
|
|
17
15
|
export * from './sql-objects/operators/logical-operator.js';
|
|
18
16
|
export * from './sql-objects/operators/op-and.js';
|
|
19
|
-
export * from './sql-objects/operators/op-
|
|
17
|
+
export * from './sql-objects/operators/op-between.js';
|
|
18
|
+
export * from './sql-objects/operators/op-eq.js';
|
|
20
19
|
export * from './sql-objects/operators/op-exists.js';
|
|
21
|
-
export * from './sql-objects/operators/op-
|
|
22
|
-
export * from './sql-objects/operators/op-
|
|
23
|
-
export * from './sql-objects/operators/op-not-in.js';
|
|
24
|
-
export * from './sql-objects/operators/op-not-between.js';
|
|
25
|
-
export * from './sql-objects/operators/op-ne.js';
|
|
20
|
+
export * from './sql-objects/operators/op-gt.js';
|
|
21
|
+
export * from './sql-objects/operators/op-gte.js';
|
|
26
22
|
export * from './sql-objects/operators/op-ilike.js';
|
|
27
|
-
export * from './sql-objects/operators/op-like.js';
|
|
28
|
-
export * from './sql-objects/operators/op-is-not.js';
|
|
29
|
-
export * from './sql-objects/operators/op-is.js';
|
|
30
23
|
export * from './sql-objects/operators/op-in.js';
|
|
31
|
-
export * from './sql-objects/operators/op-
|
|
32
|
-
export * from './sql-objects/operators/op-
|
|
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';
|
|
33
27
|
export * from './sql-objects/operators/op-lt.js';
|
|
34
|
-
export * from './sql-objects/operators/op-
|
|
35
|
-
export * from './sql-objects/operators/op-
|
|
36
|
-
export * from './sql-objects/operators/op-
|
|
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';
|
|
37
35
|
export * from './sql-objects/operators/op-or.js';
|
|
38
|
-
export * from './sql-objects/
|
|
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/extensions.js
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export class SerializerRegistry {
|
|
2
|
+
static get size() {
|
|
3
|
+
return this.serializers.length;
|
|
4
|
+
}
|
|
5
|
+
static register(...extension) {
|
|
6
|
+
for (const ext of extension) {
|
|
7
|
+
if (!ext.dialect)
|
|
8
|
+
throw new TypeError('A SerializerExtension must contain "dialect" property');
|
|
9
|
+
this.serializers.push(ext);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
static forEach(callback, thisArg) {
|
|
13
|
+
return this.serializers.forEach(callback, thisArg);
|
|
14
|
+
}
|
|
15
|
+
static items() {
|
|
16
|
+
return this.serializers.values();
|
|
17
|
+
}
|
|
18
|
+
static unRegister(...extensions) {
|
|
19
|
+
this.serializers = extensions.filter(x => !extensions.includes(x));
|
|
20
|
+
}
|
|
21
|
+
static getAll(dialect) {
|
|
22
|
+
return this.serializers.filter(x => x.dialect === dialect);
|
|
23
|
+
}
|
|
24
|
+
static get(index) {
|
|
25
|
+
return this.serializers[index];
|
|
26
|
+
}
|
|
27
|
+
static findDialect(dialect) {
|
|
28
|
+
return this.serializers.find(x => x.dialect === dialect);
|
|
29
|
+
}
|
|
30
|
+
static has(extension) {
|
|
31
|
+
return !!this.serializers.find(x => x === extension);
|
|
7
32
|
}
|
|
8
33
|
}
|
|
9
|
-
|
|
10
|
-
serializers = serializers.filter(x => !extension.includes(x));
|
|
11
|
-
}
|
|
34
|
+
SerializerRegistry.serializers = [];
|
package/esm/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * as classes from './classes.ns.js';
|
|
2
|
+
export * from './enums.js';
|
|
3
|
+
export * from './extensions.js';
|
|
2
4
|
export * from './helpers.js';
|
|
3
|
-
export * from './
|
|
4
|
-
export
|
|
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';
|
|
5
9
|
export * from './query/query.js';
|
|
6
10
|
export * from './query/select-query.js';
|
|
7
|
-
export * from './query/insert-query.js';
|
|
8
11
|
export * from './query/update-query.js';
|
|
9
|
-
export * from './
|
|
12
|
+
export * from './serializable.js';
|
|
13
|
+
export * from './serialize-context.js';
|
|
14
|
+
export * from './sql-objects/join-statement.js';
|
|
10
15
|
export * from './sql-objects/operator.js';
|
|
11
|
-
export * from './sql-objects/operators/logical-operator.js';
|
|
12
16
|
export * from './sql-objects/operators/comp-operator.js';
|
|
13
|
-
export * from './sql-objects/
|
|
14
|
-
export * from './types.js';
|
|
15
|
-
export * from './enums.js';
|
|
17
|
+
export * from './sql-objects/operators/logical-operator.js';
|
|
16
18
|
export * from './sqlobject.initializers.js';
|
|
17
|
-
export * from './op.initializers.js';
|
|
18
19
|
export * from './typeguards.js';
|
|
19
|
-
export
|
|
20
|
-
export * as classes from './classes.ns.js';
|
|
20
|
+
export * from './types.js';
|
package/esm/op.initializers.js
CHANGED
|
@@ -128,4 +128,4 @@ const op = {
|
|
|
128
128
|
};
|
|
129
129
|
Object.assign(WrapOps, op);
|
|
130
130
|
export { op };
|
|
131
|
-
export { And,
|
|
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, };
|
|
@@ -6,8 +6,9 @@ import { Query } from './query.js';
|
|
|
6
6
|
export class DeleteQuery extends Query {
|
|
7
7
|
constructor(tableName) {
|
|
8
8
|
super();
|
|
9
|
-
if (!tableName || !(typeof tableName === 'string' || isRawStatement(tableName)))
|
|
9
|
+
if (!tableName || !(typeof tableName === 'string' || isRawStatement(tableName))) {
|
|
10
10
|
throw new TypeError('String or Raw instance required as first argument (tableName) for UpdateQuery');
|
|
11
|
+
}
|
|
11
12
|
this._table = typeof tableName === 'string' ? new TableName(tableName) : tableName;
|
|
12
13
|
}
|
|
13
14
|
get _type() {
|
|
@@ -41,9 +42,8 @@ export class DeleteQuery extends Query {
|
|
|
41
42
|
if (!this._where)
|
|
42
43
|
return '';
|
|
43
44
|
const s = this._where._serialize(ctx);
|
|
44
|
-
return ctx.serialize(SerializationType.CONDITIONS_BLOCK, s, () =>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
45
|
+
return ctx.serialize(SerializationType.CONDITIONS_BLOCK, s, () =>
|
|
46
|
+
/* istanbul ignore next */
|
|
47
|
+
s ? 'where ' + s : '');
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -6,10 +6,12 @@ import { ReturningQuery } from './returning-query.js';
|
|
|
6
6
|
export class InsertQuery extends ReturningQuery {
|
|
7
7
|
constructor(tableName, input) {
|
|
8
8
|
super();
|
|
9
|
-
if (!tableName || !(typeof tableName === 'string' || isRawStatement(tableName)))
|
|
9
|
+
if (!tableName || !(typeof tableName === 'string' || isRawStatement(tableName))) {
|
|
10
10
|
throw new TypeError('String or Raw instance required as first argument (tableName) for InsertQuery');
|
|
11
|
-
|
|
11
|
+
}
|
|
12
|
+
if (!input || !((typeof input === 'object' && !Array.isArray(input)) || input.isSelect)) {
|
|
12
13
|
throw new TypeError('Object or SelectQuery instance required as second argument (input) for InsertQuery');
|
|
14
|
+
}
|
|
13
15
|
this._table = typeof tableName === 'string' ? new TableName(tableName) : tableName;
|
|
14
16
|
this._input = input;
|
|
15
17
|
}
|
|
@@ -174,7 +174,7 @@ export class SelectQuery extends Query {
|
|
|
174
174
|
*/
|
|
175
175
|
__serializeSelectColumns(ctx) {
|
|
176
176
|
const arr = [];
|
|
177
|
-
if (this._columns)
|
|
177
|
+
if (this._columns) {
|
|
178
178
|
for (const t of this._columns) {
|
|
179
179
|
const s = ctx.anyToSQL(t);
|
|
180
180
|
// t._serialize(ctx);
|
|
@@ -188,6 +188,7 @@ export class SelectQuery extends Query {
|
|
|
188
188
|
arr.push(s);
|
|
189
189
|
}
|
|
190
190
|
}
|
|
191
|
+
}
|
|
191
192
|
return ctx.serialize(SerializationType.SELECT_QUERY_COLUMNS, arr, () => printArray(arr) || '*');
|
|
192
193
|
}
|
|
193
194
|
/**
|
|
@@ -195,7 +196,7 @@ export class SelectQuery extends Query {
|
|
|
195
196
|
*/
|
|
196
197
|
__serializeFrom(ctx) {
|
|
197
198
|
const arr = [];
|
|
198
|
-
if (this._tables)
|
|
199
|
+
if (this._tables) {
|
|
199
200
|
for (const t of this._tables) {
|
|
200
201
|
const s = t._serialize(ctx);
|
|
201
202
|
/* istanbul ignore else */
|
|
@@ -209,6 +210,7 @@ export class SelectQuery extends Query {
|
|
|
209
210
|
arr.push(s);
|
|
210
211
|
}
|
|
211
212
|
}
|
|
213
|
+
}
|
|
212
214
|
return ctx.serialize(SerializationType.SELECT_QUERY_FROM, arr, () => {
|
|
213
215
|
const s = arr.join(',');
|
|
214
216
|
return s ? 'from' + (s.substring(0, 1) !== '\n' ? ' ' : '') + s : '';
|
|
@@ -219,16 +221,15 @@ export class SelectQuery extends Query {
|
|
|
219
221
|
*/
|
|
220
222
|
__serializeJoins(ctx) {
|
|
221
223
|
const arr = [];
|
|
222
|
-
if (this._joins)
|
|
224
|
+
if (this._joins) {
|
|
223
225
|
for (const t of this._joins) {
|
|
224
226
|
const s = t._serialize(ctx);
|
|
225
227
|
/* istanbul ignore else */
|
|
226
228
|
if (s)
|
|
227
229
|
arr.push(s);
|
|
228
230
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
});
|
|
231
|
+
}
|
|
232
|
+
return ctx.serialize(SerializationType.SELECT_QUERY_JOIN, arr, () => arr.join('\n'));
|
|
232
233
|
}
|
|
233
234
|
/**
|
|
234
235
|
*
|
|
@@ -237,23 +238,23 @@ export class SelectQuery extends Query {
|
|
|
237
238
|
if (!this._where)
|
|
238
239
|
return '';
|
|
239
240
|
const s = this._where._serialize(ctx);
|
|
240
|
-
return ctx.serialize(SerializationType.CONDITIONS_BLOCK, s, () =>
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
});
|
|
241
|
+
return ctx.serialize(SerializationType.CONDITIONS_BLOCK, s, () =>
|
|
242
|
+
/* istanbul ignore next */
|
|
243
|
+
s ? 'where ' + s : '');
|
|
244
244
|
}
|
|
245
245
|
/**
|
|
246
246
|
*
|
|
247
247
|
*/
|
|
248
248
|
__serializeGroupColumns(ctx) {
|
|
249
249
|
const arr = [];
|
|
250
|
-
if (this._groupBy)
|
|
250
|
+
if (this._groupBy) {
|
|
251
251
|
for (const t of this._groupBy) {
|
|
252
252
|
const s = t._serialize(ctx);
|
|
253
253
|
/* istanbul ignore else */
|
|
254
254
|
if (s)
|
|
255
255
|
arr.push(s);
|
|
256
256
|
}
|
|
257
|
+
}
|
|
257
258
|
return ctx.serialize(SerializationType.SELECT_QUERY_GROUPBY, arr, () => {
|
|
258
259
|
const s = printArray(arr);
|
|
259
260
|
return s ? 'group by ' + s : '';
|
|
@@ -261,13 +262,14 @@ export class SelectQuery extends Query {
|
|
|
261
262
|
}
|
|
262
263
|
__serializeOrderColumns(ctx) {
|
|
263
264
|
const arr = [];
|
|
264
|
-
if (this._orderBy)
|
|
265
|
+
if (this._orderBy) {
|
|
265
266
|
for (const t of this._orderBy) {
|
|
266
267
|
const s = t._serialize(ctx);
|
|
267
268
|
/* istanbul ignore else */
|
|
268
269
|
if (s)
|
|
269
270
|
arr.push(s);
|
|
270
271
|
}
|
|
272
|
+
}
|
|
271
273
|
return ctx.serialize(SerializationType.SELECT_QUERY_ORDERBY, arr, () => {
|
|
272
274
|
const s = printArray(arr);
|
|
273
275
|
return s ? 'order by ' + s : '';
|
|
@@ -7,10 +7,12 @@ import { ReturningQuery } from './returning-query.js';
|
|
|
7
7
|
export class UpdateQuery extends ReturningQuery {
|
|
8
8
|
constructor(tableName, input) {
|
|
9
9
|
super();
|
|
10
|
-
if (!tableName || !(typeof tableName === 'string' || isRawStatement(tableName)))
|
|
10
|
+
if (!tableName || !(typeof tableName === 'string' || isRawStatement(tableName))) {
|
|
11
11
|
throw new TypeError('String or Raw instance required as first argument (tableName) for UpdateQuery');
|
|
12
|
-
|
|
12
|
+
}
|
|
13
|
+
if (!input || !((typeof input === 'object' && !Array.isArray(input)) || input.isSelect)) {
|
|
13
14
|
throw new TypeError('Object or Raw instance required as second argument (input) for UpdateQuery');
|
|
15
|
+
}
|
|
14
16
|
this._table = typeof tableName === 'string' ? new TableName(tableName) : tableName;
|
|
15
17
|
this._input = input;
|
|
16
18
|
}
|
|
@@ -67,9 +69,8 @@ export class UpdateQuery extends ReturningQuery {
|
|
|
67
69
|
if (!this._where)
|
|
68
70
|
return '';
|
|
69
71
|
const s = this._where._serialize(ctx);
|
|
70
|
-
return ctx.serialize(SerializationType.CONDITIONS_BLOCK, s, () =>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
});
|
|
72
|
+
return ctx.serialize(SerializationType.CONDITIONS_BLOCK, s, () =>
|
|
73
|
+
/* istanbul ignore next */
|
|
74
|
+
s ? 'where ' + s : '');
|
|
74
75
|
}
|
|
75
76
|
}
|
package/esm/serialize-context.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SerializationType } from './enums.js';
|
|
2
|
-
import {
|
|
2
|
+
import { SerializerRegistry } from './extensions.js';
|
|
3
3
|
import { Serializable } from './serializable.js';
|
|
4
4
|
import { isLogicalOperator, isQuery, isSerializable } from './typeguards.js';
|
|
5
5
|
export class SerializeContext {
|
|
@@ -76,7 +76,7 @@ export class SerializeContext {
|
|
|
76
76
|
return s;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
for (const ext of
|
|
79
|
+
for (const ext of SerializerRegistry.items()) {
|
|
80
80
|
if (ext.dialect === this.dialect && ext.serialize) {
|
|
81
81
|
const s = ext.serialize(this, type, o, fallback);
|
|
82
82
|
if (s != null)
|
|
@@ -160,7 +160,7 @@ export class SerializeContext {
|
|
|
160
160
|
return false;
|
|
161
161
|
if (this.reservedWords.includes(s.toLowerCase()))
|
|
162
162
|
return true;
|
|
163
|
-
for (const ext of
|
|
163
|
+
for (const ext of SerializerRegistry.items()) {
|
|
164
164
|
if (ext.dialect === this.dialect && ext.isReservedWord) {
|
|
165
165
|
if (ext.isReservedWord(this, s))
|
|
166
166
|
return true;
|
|
@@ -23,11 +23,12 @@ export class CaseStatement extends Serializable {
|
|
|
23
23
|
* Defines "then" part of Case expression.
|
|
24
24
|
*/
|
|
25
25
|
then(value) {
|
|
26
|
-
if (this._condition)
|
|
26
|
+
if (this._condition) {
|
|
27
27
|
this._expressions.push({
|
|
28
28
|
condition: this._condition,
|
|
29
29
|
value,
|
|
30
30
|
});
|
|
31
|
+
}
|
|
31
32
|
return this;
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
@@ -25,10 +25,8 @@ export class GroupColumn extends BaseField {
|
|
|
25
25
|
field: this._field,
|
|
26
26
|
isReservedWord: !!(this._field && ctx.isReservedWord(this._field)),
|
|
27
27
|
};
|
|
28
|
-
return ctx.serialize(this._type, o, () =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
(o.isReservedWord ? '"' + this._field + '"' : this._field));
|
|
32
|
-
});
|
|
28
|
+
return ctx.serialize(this._type, o, () => (this._schema ? this._schema + '.' : '') +
|
|
29
|
+
(this._table ? this._table + '.' : '') +
|
|
30
|
+
(o.isReservedWord ? '"' + this._field + '"' : this._field));
|
|
33
31
|
}
|
|
34
32
|
}
|
|
@@ -8,8 +8,9 @@ export class JoinStatement extends Serializable {
|
|
|
8
8
|
super();
|
|
9
9
|
this._conditions = new OpAnd();
|
|
10
10
|
// noinspection SuspiciousTypeOfGuard
|
|
11
|
-
if (!(isSelectQuery(table) || isRawStatement(table) || isTableName(table) || typeof table === 'string'))
|
|
11
|
+
if (!(isSelectQuery(table) || isRawStatement(table) || isTableName(table) || typeof table === 'string')) {
|
|
12
12
|
throw new TypeError('Table name, select query or raw object required for Join');
|
|
13
|
+
}
|
|
13
14
|
this._joinType = joinType;
|
|
14
15
|
this._table = typeof table === 'string' ? new TableName(table) : table;
|
|
15
16
|
}
|
|
@@ -59,7 +60,7 @@ export class JoinStatement extends Serializable {
|
|
|
59
60
|
const alias = this._table._alias;
|
|
60
61
|
if (!alias)
|
|
61
62
|
throw new Error('Alias required for sub-select in Join');
|
|
62
|
-
out += ' (' + (lf ? '\n\t' : '') + o.table + (lf ? '\n\b' : '') + ')
|
|
63
|
+
out += ' (' + (lf ? '\n\t' : '') + o.table + (lf ? '\n\b' : '') + ') ' + alias;
|
|
63
64
|
}
|
|
64
65
|
else
|
|
65
66
|
out += ' ' + o.table;
|