@sqb/builder 4.8.2 → 4.9.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/cjs/enums.js +6 -4
- package/cjs/op.initializers.js +7 -1
- package/cjs/sql-objects/field-expression.js +2 -2
- package/cjs/sql-objects/operators/logical-operator.js +1 -1
- package/cjs/sql-objects/operators/op-not.js +23 -0
- package/cjs/typeguards.js +5 -1
- package/esm/enums.d.ts +3 -1
- package/esm/enums.js +2 -0
- package/esm/op.initializers.d.ts +8 -5
- package/esm/op.initializers.js +6 -1
- package/esm/sql-objects/field-expression.js +2 -2
- package/esm/sql-objects/operators/logical-operator.js +2 -2
- package/esm/sql-objects/operators/op-not.d.ts +11 -0
- package/esm/sql-objects/operators/op-not.js +19 -0
- package/esm/typeguards.d.ts +1 -0
- package/esm/typeguards.js +3 -0
- package/package.json +2 -2
package/cjs/enums.js
CHANGED
|
@@ -11,7 +11,7 @@ var JoinType;
|
|
|
11
11
|
JoinType["OUTER"] = "outer";
|
|
12
12
|
JoinType["FULL_OUTER"] = "full outer";
|
|
13
13
|
JoinType["CROSS"] = "cross";
|
|
14
|
-
})(JoinType
|
|
14
|
+
})(JoinType || (exports.JoinType = JoinType = {}));
|
|
15
15
|
var SerializationType;
|
|
16
16
|
(function (SerializationType) {
|
|
17
17
|
SerializationType["SELECT_QUERY"] = "select_query";
|
|
@@ -46,6 +46,7 @@ var SerializationType;
|
|
|
46
46
|
SerializationType["CONDITIONS_BLOCK"] = "conditions_block";
|
|
47
47
|
SerializationType["COMPARISON_EXPRESSION"] = "comparison_expression";
|
|
48
48
|
SerializationType["LOGICAL_EXPRESSION"] = "logical_expression";
|
|
49
|
+
SerializationType["NEGATIVE_EXPRESSION"] = "negative_expression";
|
|
49
50
|
SerializationType["RETURNING_BLOCK"] = "returning_block";
|
|
50
51
|
SerializationType["DATE_VALUE"] = "date_value";
|
|
51
52
|
SerializationType["STRING_VALUE"] = "string_value";
|
|
@@ -53,7 +54,7 @@ var SerializationType;
|
|
|
53
54
|
SerializationType["NUMBER_VALUE"] = "number_value";
|
|
54
55
|
SerializationType["EXTERNAL_PARAMETER"] = "external_parameter";
|
|
55
56
|
SerializationType["ARRAY"] = "array";
|
|
56
|
-
})(SerializationType
|
|
57
|
+
})(SerializationType || (exports.SerializationType = SerializationType = {}));
|
|
57
58
|
var OperatorType;
|
|
58
59
|
(function (OperatorType) {
|
|
59
60
|
OperatorType["and"] = "and";
|
|
@@ -76,7 +77,8 @@ var OperatorType;
|
|
|
76
77
|
OperatorType["isNot"] = "isNot";
|
|
77
78
|
OperatorType["exists"] = "exists";
|
|
78
79
|
OperatorType["notExists"] = "notExists";
|
|
79
|
-
|
|
80
|
+
OperatorType["not"] = "not";
|
|
81
|
+
})(OperatorType || (exports.OperatorType = OperatorType = {}));
|
|
80
82
|
var DataType;
|
|
81
83
|
(function (DataType) {
|
|
82
84
|
DataType["BOOL"] = "BOOL";
|
|
@@ -96,4 +98,4 @@ var DataType;
|
|
|
96
98
|
DataType["TEXT"] = "TEXT";
|
|
97
99
|
DataType["GUID"] = "GUID";
|
|
98
100
|
DataType["JSON"] = "JSON";
|
|
99
|
-
})(DataType
|
|
101
|
+
})(DataType || (exports.DataType = DataType = {}));
|
package/cjs/op.initializers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotExists = exports.Exists = exports.IsNot = exports.Is = exports.Nilike = exports.NotILike = exports.Ilike = exports.NLike = exports.NotLike = exports.Like = exports.Nin = exports.NotIn = exports.In = exports.NotBetween = exports.Between = exports.LowerAndEqualTo = exports.Lte = exports.LowerThan = exports.Lt = exports.GreaterAnEqualTo = exports.Gte = exports.GreaterThan = exports.Gt = exports.NotEqual = exports.Ne = exports.Equal = exports.Eq = exports.Or = exports.And = exports.op = void 0;
|
|
3
|
+
exports.Not = exports.NotExists = exports.Exists = exports.IsNot = exports.Is = exports.Nilike = exports.NotILike = exports.Ilike = exports.NLike = exports.NotLike = exports.Like = exports.Nin = exports.NotIn = exports.In = exports.NotBetween = exports.Between = exports.LowerAndEqualTo = exports.Lte = exports.LowerThan = exports.Lt = exports.GreaterAnEqualTo = exports.Gte = exports.GreaterThan = exports.Gt = exports.NotEqual = exports.Ne = exports.Equal = exports.Eq = exports.Or = exports.And = exports.op = void 0;
|
|
4
4
|
const logical_operator_js_1 = require("./sql-objects/operators/logical-operator.js");
|
|
5
5
|
const op_and_js_1 = require("./sql-objects/operators/op-and.js");
|
|
6
6
|
const op_between_js_1 = require("./sql-objects/operators/op-between.js");
|
|
@@ -16,6 +16,7 @@ const op_like_js_1 = require("./sql-objects/operators/op-like.js");
|
|
|
16
16
|
const op_lt_js_1 = require("./sql-objects/operators/op-lt.js");
|
|
17
17
|
const op_lte_js_1 = require("./sql-objects/operators/op-lte.js");
|
|
18
18
|
const op_ne_js_1 = require("./sql-objects/operators/op-ne.js");
|
|
19
|
+
const op_not_js_1 = require("./sql-objects/operators/op-not.js");
|
|
19
20
|
const op_not_between_js_1 = require("./sql-objects/operators/op-not-between.js");
|
|
20
21
|
const op_not_exists_js_1 = require("./sql-objects/operators/op-not-exists.js");
|
|
21
22
|
const op_not_ilike_js_1 = require("./sql-objects/operators/op-not-ilike.js");
|
|
@@ -113,6 +114,10 @@ function NotExists(expression) {
|
|
|
113
114
|
return new op_not_exists_js_1.OpNotExists(expression);
|
|
114
115
|
}
|
|
115
116
|
exports.NotExists = NotExists;
|
|
117
|
+
function Not(expression) {
|
|
118
|
+
return new op_not_js_1.OpNot(expression);
|
|
119
|
+
}
|
|
120
|
+
exports.Not = Not;
|
|
116
121
|
const op = {
|
|
117
122
|
and: And,
|
|
118
123
|
or: Or,
|
|
@@ -139,6 +144,7 @@ const op = {
|
|
|
139
144
|
nin: NotIn,
|
|
140
145
|
'!in': NotIn,
|
|
141
146
|
like: Like,
|
|
147
|
+
not: Not,
|
|
142
148
|
notLike: NotLike,
|
|
143
149
|
nlike: NotLike,
|
|
144
150
|
'!like': NotLike,
|
|
@@ -19,9 +19,9 @@ class FieldExpression extends base_field_js_1.BaseField {
|
|
|
19
19
|
this._dataType = arg1;
|
|
20
20
|
this._isArray = arg2;
|
|
21
21
|
}
|
|
22
|
-
const m = expression
|
|
22
|
+
const m = expression?.match(TABLE_COLUMN_PATTERN);
|
|
23
23
|
if (!m)
|
|
24
|
-
throw new TypeError(
|
|
24
|
+
throw new TypeError(`"${expression}" does not match table column format`);
|
|
25
25
|
this._field = m[2];
|
|
26
26
|
if (m[1]) {
|
|
27
27
|
const a = m[1].split(/\./g);
|
|
@@ -29,7 +29,7 @@ class LogicalOperator extends operator_js_1.Operator {
|
|
|
29
29
|
if ((0, typeguards_js_1.isLogicalOperator)(item)) {
|
|
30
30
|
this._items.push(item);
|
|
31
31
|
}
|
|
32
|
-
else if ((0, typeguards_js_1.isRawStatement)(item) || (0, typeguards_js_1.isCompOperator)(item)) {
|
|
32
|
+
else if ((0, typeguards_js_1.isRawStatement)(item) || (0, typeguards_js_1.isCompOperator)(item) || (0, typeguards_js_1.isNotOperator)(item)) {
|
|
33
33
|
this._items.push(item);
|
|
34
34
|
}
|
|
35
35
|
else if ((0, putil_isplainobject_1.default)(item)) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpNot = void 0;
|
|
4
|
+
const enums_js_1 = require("../../enums.js");
|
|
5
|
+
const operator_js_1 = require("../operator.js");
|
|
6
|
+
class OpNot extends operator_js_1.Operator {
|
|
7
|
+
_operatorType = enums_js_1.OperatorType.not;
|
|
8
|
+
_expression;
|
|
9
|
+
constructor(expression) {
|
|
10
|
+
super();
|
|
11
|
+
this._expression = expression;
|
|
12
|
+
}
|
|
13
|
+
get _type() {
|
|
14
|
+
return enums_js_1.SerializationType.NEGATIVE_EXPRESSION;
|
|
15
|
+
}
|
|
16
|
+
_serialize(ctx) {
|
|
17
|
+
const expression = ctx.anyToSQL(this._expression);
|
|
18
|
+
return ctx.serialize(this._type, expression, () => {
|
|
19
|
+
return expression ? 'not ' + expression : '';
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.OpNot = OpNot;
|
package/cjs/typeguards.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isTableName = exports.isReturningColumn = exports.isGroupColumn = exports.isOrderColumn = exports.isSelectColumn = exports.isCompOperator = exports.isLogicalOperator = exports.isParamExpression = exports.isCountStatement = exports.isCaseStatement = exports.isJoinStatement = exports.isDeleteQuery = exports.isIUpdateQuery = exports.isInsertQuery = exports.isSelectQuery = exports.isRawStatement = exports.isQuery = exports.isSerializable = void 0;
|
|
3
|
+
exports.isTableName = exports.isReturningColumn = exports.isGroupColumn = exports.isOrderColumn = exports.isSelectColumn = exports.isNotOperator = exports.isCompOperator = exports.isLogicalOperator = exports.isParamExpression = exports.isCountStatement = exports.isCaseStatement = exports.isJoinStatement = exports.isDeleteQuery = exports.isIUpdateQuery = exports.isInsertQuery = exports.isSelectQuery = exports.isRawStatement = exports.isQuery = exports.isSerializable = void 0;
|
|
4
4
|
const enums_js_1 = require("./enums.js");
|
|
5
5
|
const query_js_1 = require("./query/query.js");
|
|
6
6
|
const serializable_js_1 = require("./serializable.js");
|
|
@@ -56,6 +56,10 @@ function isCompOperator(value) {
|
|
|
56
56
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.COMPARISON_EXPRESSION;
|
|
57
57
|
}
|
|
58
58
|
exports.isCompOperator = isCompOperator;
|
|
59
|
+
function isNotOperator(value) {
|
|
60
|
+
return isSerializable(value) && value._type === enums_js_1.SerializationType.NEGATIVE_EXPRESSION;
|
|
61
|
+
}
|
|
62
|
+
exports.isNotOperator = isNotOperator;
|
|
59
63
|
function isSelectColumn(value) {
|
|
60
64
|
return isSerializable(value) && value._type === enums_js_1.SerializationType.FIELD_NAME;
|
|
61
65
|
}
|
package/esm/enums.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export declare enum SerializationType {
|
|
|
41
41
|
CONDITIONS_BLOCK = "conditions_block",
|
|
42
42
|
COMPARISON_EXPRESSION = "comparison_expression",
|
|
43
43
|
LOGICAL_EXPRESSION = "logical_expression",
|
|
44
|
+
NEGATIVE_EXPRESSION = "negative_expression",
|
|
44
45
|
RETURNING_BLOCK = "returning_block",
|
|
45
46
|
DATE_VALUE = "date_value",
|
|
46
47
|
STRING_VALUE = "string_value",
|
|
@@ -69,7 +70,8 @@ export declare enum OperatorType {
|
|
|
69
70
|
is = "is",
|
|
70
71
|
isNot = "isNot",
|
|
71
72
|
exists = "exists",
|
|
72
|
-
notExists = "notExists"
|
|
73
|
+
notExists = "notExists",
|
|
74
|
+
not = "not"
|
|
73
75
|
}
|
|
74
76
|
export declare enum DataType {
|
|
75
77
|
BOOL = "BOOL",
|
package/esm/enums.js
CHANGED
|
@@ -43,6 +43,7 @@ export var SerializationType;
|
|
|
43
43
|
SerializationType["CONDITIONS_BLOCK"] = "conditions_block";
|
|
44
44
|
SerializationType["COMPARISON_EXPRESSION"] = "comparison_expression";
|
|
45
45
|
SerializationType["LOGICAL_EXPRESSION"] = "logical_expression";
|
|
46
|
+
SerializationType["NEGATIVE_EXPRESSION"] = "negative_expression";
|
|
46
47
|
SerializationType["RETURNING_BLOCK"] = "returning_block";
|
|
47
48
|
SerializationType["DATE_VALUE"] = "date_value";
|
|
48
49
|
SerializationType["STRING_VALUE"] = "string_value";
|
|
@@ -73,6 +74,7 @@ export var OperatorType;
|
|
|
73
74
|
OperatorType["isNot"] = "isNot";
|
|
74
75
|
OperatorType["exists"] = "exists";
|
|
75
76
|
OperatorType["notExists"] = "notExists";
|
|
77
|
+
OperatorType["not"] = "not";
|
|
76
78
|
})(OperatorType || (OperatorType = {}));
|
|
77
79
|
export var DataType;
|
|
78
80
|
(function (DataType) {
|
package/esm/op.initializers.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SelectQuery } from './query/select-query.js';
|
|
2
2
|
import { Serializable } from './serializable.js';
|
|
3
|
-
import { Operator } from './sql-objects/operator.js';
|
|
4
3
|
import { OpAnd } from './sql-objects/operators/op-and.js';
|
|
5
4
|
import { OpEq } from './sql-objects/operators/op-eq.js';
|
|
6
5
|
import { OpExists } from './sql-objects/operators/op-exists.js';
|
|
@@ -14,22 +13,24 @@ import { OpLike } from './sql-objects/operators/op-like.js';
|
|
|
14
13
|
import { OpLt } from './sql-objects/operators/op-lt.js';
|
|
15
14
|
import { OpLte } from './sql-objects/operators/op-lte.js';
|
|
16
15
|
import { OpNe } from './sql-objects/operators/op-ne.js';
|
|
16
|
+
import { OpNot } from './sql-objects/operators/op-not.js';
|
|
17
17
|
import { OpNotExists } from './sql-objects/operators/op-not-exists.js';
|
|
18
18
|
import { OpNotILike } from './sql-objects/operators/op-not-ilike.js';
|
|
19
19
|
import { OpNotIn } from './sql-objects/operators/op-not-in.js';
|
|
20
20
|
import { OpNotLike } from './sql-objects/operators/op-not-like.js';
|
|
21
21
|
import { OpOr } from './sql-objects/operators/op-or.js';
|
|
22
|
-
|
|
23
|
-
declare function
|
|
24
|
-
declare function Or(...args: (Operator | RawStatement)[]): OpOr;
|
|
22
|
+
declare function And(...args: (Serializable | Object)[]): OpAnd;
|
|
23
|
+
declare function Or(...args: (Serializable | Object)[]): OpOr;
|
|
25
24
|
declare function Eq(expression: string | Serializable, value: any): OpEq;
|
|
26
25
|
declare function Ne(expression: string | Serializable, value: any): OpNe;
|
|
27
26
|
declare function Gt(expression: string | Serializable, value: any): OpGt;
|
|
28
27
|
declare function Gte(expression: string | Serializable, value: any): OpGte;
|
|
29
28
|
declare function Lt(expression: string | Serializable, value: any): OpLt;
|
|
30
29
|
declare function Lte(expression: string | Serializable, value: any): OpLte;
|
|
30
|
+
declare function Between(expression: string | Serializable, values: Serializable): any;
|
|
31
31
|
declare function Between(expression: string | Serializable, values: any[]): any;
|
|
32
32
|
declare function Between(expression: string | Serializable, value1: any, value2: any): any;
|
|
33
|
+
declare function NotBetween(expression: string | Serializable, values: Serializable): any;
|
|
33
34
|
declare function NotBetween(expression: string | Serializable, values: any[]): any;
|
|
34
35
|
declare function NotBetween(expression: string | Serializable, value1: any, value2: any): any;
|
|
35
36
|
declare function In(expression: string | Serializable, value: any): OpIn;
|
|
@@ -42,6 +43,7 @@ declare function Is(expression: string | Serializable, value: any): OpIs;
|
|
|
42
43
|
declare function IsNot(expression: string | Serializable, value: any): OpIsNot;
|
|
43
44
|
declare function Exists(expression: SelectQuery): OpExists;
|
|
44
45
|
declare function NotExists(expression: SelectQuery): OpNotExists;
|
|
46
|
+
declare function Not(expression: Serializable): OpNot;
|
|
45
47
|
declare const op: {
|
|
46
48
|
and: typeof And;
|
|
47
49
|
or: typeof Or;
|
|
@@ -68,6 +70,7 @@ declare const op: {
|
|
|
68
70
|
nin: typeof NotIn;
|
|
69
71
|
'!in': typeof NotIn;
|
|
70
72
|
like: typeof Like;
|
|
73
|
+
not: typeof Not;
|
|
71
74
|
notLike: typeof NotLike;
|
|
72
75
|
nlike: typeof NotLike;
|
|
73
76
|
'!like': typeof NotLike;
|
|
@@ -83,4 +86,4 @@ declare const op: {
|
|
|
83
86
|
'!exists': typeof NotExists;
|
|
84
87
|
};
|
|
85
88
|
export { op };
|
|
86
|
-
export { And, Or, Eq, Eq as Equal, Ne, Ne as NotEqual, Gt, Gt as GreaterThan, Gte, Gte as GreaterAnEqualTo, Lt, Lt as LowerThan, Lte, Lte as LowerAndEqualTo, Between, NotBetween, In, NotIn, NotIn as Nin, Like, NotLike, NotLike as NLike, Ilike, NotILike, NotILike as Nilike, Is, IsNot, Exists, NotExists };
|
|
89
|
+
export { And, Or, Eq, Eq as Equal, Ne, Ne as NotEqual, Gt, Gt as GreaterThan, Gte, Gte as GreaterAnEqualTo, Lt, Lt as LowerThan, Lte, Lte as LowerAndEqualTo, Between, NotBetween, In, NotIn, NotIn as Nin, Like, NotLike, NotLike as NLike, Ilike, NotILike, NotILike as Nilike, Is, IsNot, Exists, NotExists, Not };
|
package/esm/op.initializers.js
CHANGED
|
@@ -13,6 +13,7 @@ import { OpLike } from './sql-objects/operators/op-like.js';
|
|
|
13
13
|
import { OpLt } from './sql-objects/operators/op-lt.js';
|
|
14
14
|
import { OpLte } from './sql-objects/operators/op-lte.js';
|
|
15
15
|
import { OpNe } from './sql-objects/operators/op-ne.js';
|
|
16
|
+
import { OpNot } from './sql-objects/operators/op-not.js';
|
|
16
17
|
import { OpNotBetween } from './sql-objects/operators/op-not-between.js';
|
|
17
18
|
import { OpNotExists } from './sql-objects/operators/op-not-exists.js';
|
|
18
19
|
import { OpNotILike } from './sql-objects/operators/op-not-ilike.js';
|
|
@@ -81,6 +82,9 @@ function Exists(expression) {
|
|
|
81
82
|
function NotExists(expression) {
|
|
82
83
|
return new OpNotExists(expression);
|
|
83
84
|
}
|
|
85
|
+
function Not(expression) {
|
|
86
|
+
return new OpNot(expression);
|
|
87
|
+
}
|
|
84
88
|
const op = {
|
|
85
89
|
and: And,
|
|
86
90
|
or: Or,
|
|
@@ -107,6 +111,7 @@ const op = {
|
|
|
107
111
|
nin: NotIn,
|
|
108
112
|
'!in': NotIn,
|
|
109
113
|
like: Like,
|
|
114
|
+
not: Not,
|
|
110
115
|
notLike: NotLike,
|
|
111
116
|
nlike: NotLike,
|
|
112
117
|
'!like': NotLike,
|
|
@@ -123,4 +128,4 @@ const op = {
|
|
|
123
128
|
};
|
|
124
129
|
Object.assign(WrapOps, op);
|
|
125
130
|
export { op };
|
|
126
|
-
export { And, Or, Eq, Eq as Equal, Ne, Ne as NotEqual, Gt, Gt as GreaterThan, Gte, Gte as GreaterAnEqualTo, Lt, Lt as LowerThan, Lte, Lte as LowerAndEqualTo, Between, NotBetween, In, NotIn, NotIn as Nin, Like, NotLike, NotLike as NLike, Ilike, NotILike, NotILike as Nilike, Is, IsNot, Exists, NotExists };
|
|
131
|
+
export { And, Or, Eq, Eq as Equal, Ne, Ne as NotEqual, Gt, Gt as GreaterThan, Gte, Gte as GreaterAnEqualTo, Lt, Lt as LowerThan, Lte, Lte as LowerAndEqualTo, Between, NotBetween, In, NotIn, NotIn as Nin, Like, NotLike, NotLike as NLike, Ilike, NotILike, NotILike as Nilike, Is, IsNot, Exists, NotExists, Not };
|
|
@@ -16,9 +16,9 @@ export class FieldExpression extends BaseField {
|
|
|
16
16
|
this._dataType = arg1;
|
|
17
17
|
this._isArray = arg2;
|
|
18
18
|
}
|
|
19
|
-
const m = expression
|
|
19
|
+
const m = expression?.match(TABLE_COLUMN_PATTERN);
|
|
20
20
|
if (!m)
|
|
21
|
-
throw new TypeError(
|
|
21
|
+
throw new TypeError(`"${expression}" does not match table column format`);
|
|
22
22
|
this._field = m[2];
|
|
23
23
|
if (m[1]) {
|
|
24
24
|
const a = m[1].split(/\./g);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import isPlainObject from 'putil-isplainobject';
|
|
2
2
|
import { SerializationType } from '../../enums.js';
|
|
3
3
|
import { printArray } from '../../helpers.js';
|
|
4
|
-
import { isCompOperator, isLogicalOperator, isRawStatement } from '../../typeguards.js';
|
|
4
|
+
import { isCompOperator, isLogicalOperator, isNotOperator, isRawStatement } from '../../typeguards.js';
|
|
5
5
|
import { Operator } from '../operator.js';
|
|
6
6
|
export const WrapOps = {};
|
|
7
7
|
// noinspection RegExpUnnecessaryNonCapturingGroup
|
|
@@ -25,7 +25,7 @@ export class LogicalOperator extends Operator {
|
|
|
25
25
|
if (isLogicalOperator(item)) {
|
|
26
26
|
this._items.push(item);
|
|
27
27
|
}
|
|
28
|
-
else if (isRawStatement(item) || isCompOperator(item)) {
|
|
28
|
+
else if (isRawStatement(item) || isCompOperator(item) || isNotOperator(item)) {
|
|
29
29
|
this._items.push(item);
|
|
30
30
|
}
|
|
31
31
|
else if (isPlainObject(item)) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OperatorType, SerializationType } from '../../enums.js';
|
|
2
|
+
import { Serializable } from '../../serializable.js';
|
|
3
|
+
import { SerializeContext } from '../../serialize-context.js';
|
|
4
|
+
import { Operator } from '../operator.js';
|
|
5
|
+
export declare class OpNot extends Operator {
|
|
6
|
+
_operatorType: OperatorType;
|
|
7
|
+
_expression: Serializable;
|
|
8
|
+
constructor(expression: Serializable);
|
|
9
|
+
get _type(): SerializationType;
|
|
10
|
+
_serialize(ctx: SerializeContext): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OperatorType, SerializationType } from '../../enums.js';
|
|
2
|
+
import { Operator } from '../operator.js';
|
|
3
|
+
export class OpNot extends Operator {
|
|
4
|
+
_operatorType = OperatorType.not;
|
|
5
|
+
_expression;
|
|
6
|
+
constructor(expression) {
|
|
7
|
+
super();
|
|
8
|
+
this._expression = expression;
|
|
9
|
+
}
|
|
10
|
+
get _type() {
|
|
11
|
+
return SerializationType.NEGATIVE_EXPRESSION;
|
|
12
|
+
}
|
|
13
|
+
_serialize(ctx) {
|
|
14
|
+
const expression = ctx.anyToSQL(this._expression);
|
|
15
|
+
return ctx.serialize(this._type, expression, () => {
|
|
16
|
+
return expression ? 'not ' + expression : '';
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
package/esm/typeguards.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare function isCountStatement(value: any): value is CountStatement;
|
|
|
28
28
|
export declare function isParamExpression(value: any): value is ParamExpression;
|
|
29
29
|
export declare function isLogicalOperator(value: any): value is LogicalOperator;
|
|
30
30
|
export declare function isCompOperator(value: any): value is CompOperator;
|
|
31
|
+
export declare function isNotOperator(value: any): value is CompOperator;
|
|
31
32
|
export declare function isSelectColumn(value: any): value is FieldExpression;
|
|
32
33
|
export declare function isOrderColumn(value: any): value is OrderColumn;
|
|
33
34
|
export declare function isGroupColumn(value: any): value is GroupColumn;
|
package/esm/typeguards.js
CHANGED
|
@@ -40,6 +40,9 @@ export function isLogicalOperator(value) {
|
|
|
40
40
|
export function isCompOperator(value) {
|
|
41
41
|
return isSerializable(value) && value._type === SerializationType.COMPARISON_EXPRESSION;
|
|
42
42
|
}
|
|
43
|
+
export function isNotOperator(value) {
|
|
44
|
+
return isSerializable(value) && value._type === SerializationType.NEGATIVE_EXPRESSION;
|
|
45
|
+
}
|
|
43
46
|
export function isSelectColumn(value) {
|
|
44
47
|
return isSerializable(value) && value._type === SerializationType.FIELD_NAME;
|
|
45
48
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/builder",
|
|
3
3
|
"description": "Extensible multi-dialect SQL query builder written with TypeScript",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.9.1",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"private": false,
|
|
7
7
|
"contributors": [
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"putil-varhelpers": "^1.6.5"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@types/debug": "^4.1.
|
|
40
|
+
"@types/debug": "^4.1.8"
|
|
41
41
|
},
|
|
42
42
|
"type": "module",
|
|
43
43
|
"types": "esm/index.d.ts",
|