@sqb/builder 4.2.1 → 4.5.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/README.md +2 -2
- package/cjs/classes.ns.js +41 -0
- package/{dist → cjs}/enums.js +3 -0
- package/{dist → cjs}/extensions.js +0 -0
- package/{dist → cjs}/helpers.js +0 -0
- package/cjs/index.js +27 -0
- package/{dist → cjs}/op.initializers.js +42 -42
- package/cjs/package.json +3 -0
- package/{dist/query/DeleteQuery.js → cjs/query/delete-query.js} +13 -11
- package/{dist/query/InsertQuery.js → cjs/query/insert-query.js} +15 -13
- package/{dist/query/Query.js → cjs/query/query.js} +5 -4
- package/{dist/query/ReturningQuery.js → cjs/query/returning-query.js} +9 -8
- package/cjs/query/select-query.js +294 -0
- package/{dist/query/UpdateQuery.js → cjs/query/update-query.js} +17 -14
- package/{dist/Serializable.js → cjs/serializable.js} +0 -0
- package/{dist/SerializeContext.js → cjs/serialize-context.js} +36 -26
- package/cjs/sql-objects/base-field.js +11 -0
- package/{dist/sql-objects/CaseStatement.js → cjs/sql-objects/case-statement.js} +10 -6
- package/{dist/sql-objects/CoalesceStatement.js → cjs/sql-objects/coalesce-statement.js} +6 -4
- package/{dist/sql-objects/CountStatement.js → cjs/sql-objects/count-statement.js} +5 -4
- package/cjs/sql-objects/expression.js +10 -0
- package/{dist/sql-objects/FieldExpression.js → cjs/sql-objects/field-expression.js} +5 -4
- package/{dist/sql-objects/GroupColumn.js → cjs/sql-objects/group-column.js} +4 -4
- package/{dist/sql-objects/JoinStatement.js → cjs/sql-objects/join-statement.js} +20 -18
- package/{dist/sql-objects/LowerStatement.js → cjs/sql-objects/lower-statement.js} +6 -4
- package/cjs/sql-objects/max-statement.js +41 -0
- package/cjs/sql-objects/min-statement.js +41 -0
- package/{dist/sql-objects/Operator.js → cjs/sql-objects/operator.js} +2 -2
- package/{dist/sql-objects/operators/CompOperator.js → cjs/sql-objects/operators/comp-operator.js} +17 -13
- package/{dist/sql-objects/operators/LogicalOperator.js → cjs/sql-objects/operators/logical-operator.js} +11 -11
- package/cjs/sql-objects/operators/op-and.js +9 -0
- package/{dist/sql-objects/operators/OpBetween.js → cjs/sql-objects/operators/op-between.js} +5 -5
- package/cjs/sql-objects/operators/op-eq.js +13 -0
- package/{dist/sql-objects/operators/OpExists.js → cjs/sql-objects/operators/op-exists.js} +7 -7
- package/cjs/sql-objects/operators/op-gt.js +13 -0
- package/cjs/sql-objects/operators/op-gte.js +13 -0
- package/cjs/sql-objects/operators/op-ilike.js +10 -0
- package/cjs/sql-objects/operators/op-in.js +19 -0
- package/cjs/sql-objects/operators/op-is-not.js +13 -0
- package/cjs/sql-objects/operators/op-is.js +13 -0
- package/{dist/sql-objects/operators/OpLike.js → cjs/sql-objects/operators/op-like.js} +7 -7
- package/cjs/sql-objects/operators/op-lt.js +13 -0
- package/cjs/sql-objects/operators/op-lte.js +13 -0
- package/cjs/sql-objects/operators/op-ne.js +13 -0
- package/cjs/sql-objects/operators/op-not-between.js +10 -0
- package/cjs/sql-objects/operators/op-not-exists.js +10 -0
- package/cjs/sql-objects/operators/op-not-ilike.js +10 -0
- package/cjs/sql-objects/operators/op-not-in.js +10 -0
- package/cjs/sql-objects/operators/op-not-like.js +10 -0
- package/cjs/sql-objects/operators/op-or.js +9 -0
- package/{dist/sql-objects/OrderColumn.js → cjs/sql-objects/order-column.js} +5 -4
- package/{dist/sql-objects/ParamExpression.js → cjs/sql-objects/param-expression.js} +7 -4
- package/{dist/sql-objects/RawStatement.js → cjs/sql-objects/raw-statement.js} +5 -4
- package/{dist/sql-objects/ReturningColumn.js → cjs/sql-objects/returning-column.js} +5 -4
- package/cjs/sql-objects/sequence-getter-statement.js +51 -0
- package/cjs/sql-objects/string-agg-statement.js +82 -0
- package/{dist/sql-objects/TableName.js → cjs/sql-objects/table-name.js} +7 -4
- package/{dist/sql-objects/UpperStatement.js → cjs/sql-objects/upper-statement.js} +6 -4
- package/cjs/sqlobject.initializers.js +129 -0
- package/{dist → cjs}/typeguards.js +21 -21
- package/{dist → cjs}/types.js +0 -0
- package/esm/classes.ns.d.ts +38 -0
- package/esm/classes.ns.js +38 -0
- package/{dist → esm}/enums.d.ts +3 -0
- package/esm/enums.js +95 -0
- package/{dist → esm}/extensions.d.ts +1 -1
- package/esm/extensions.js +11 -0
- package/{dist → esm}/helpers.d.ts +0 -0
- package/esm/helpers.js +27 -0
- package/esm/index.d.ts +20 -0
- package/esm/index.js +20 -0
- package/{dist → esm}/op.initializers.d.ts +22 -22
- package/esm/op.initializers.js +126 -0
- package/{dist/query/DeleteQuery.d.ts → esm/query/delete-query.d.ts} +6 -6
- package/esm/query/delete-query.js +51 -0
- package/{dist/query/InsertQuery.d.ts → esm/query/insert-query.d.ts} +5 -5
- package/esm/query/insert-query.js +73 -0
- package/{dist/query/Query.d.ts → esm/query/query.d.ts} +2 -2
- package/esm/query/query.js +36 -0
- package/{dist/query/ReturningQuery.d.ts → esm/query/returning-query.d.ts} +3 -3
- package/esm/query/returning-query.js +41 -0
- package/{dist/query/SelectQuery.d.ts → esm/query/select-query.d.ts} +9 -9
- package/{dist/query/SelectQuery.js → esm/query/select-query.js} +38 -32
- package/{dist/query/UpdateQuery.d.ts → esm/query/update-query.d.ts} +6 -6
- package/esm/query/update-query.js +79 -0
- package/{dist/Serializable.d.ts → esm/serializable.d.ts} +2 -2
- package/esm/serializable.js +2 -0
- package/{dist/SerializeContext.d.ts → esm/serialize-context.d.ts} +1 -1
- package/esm/serialize-context.js +145 -0
- package/{dist/sql-objects/BaseField.d.ts → esm/sql-objects/base-field.d.ts} +1 -1
- package/esm/sql-objects/base-field.js +7 -0
- package/{dist/sql-objects/CaseStatement.d.ts → esm/sql-objects/case-statement.d.ts} +6 -6
- package/esm/sql-objects/case-statement.js +85 -0
- package/{dist/sql-objects/CoalesceStatement.d.ts → esm/sql-objects/coalesce-statement.d.ts} +3 -3
- package/esm/sql-objects/coalesce-statement.js +42 -0
- package/{dist/sql-objects/CountStatement.d.ts → esm/sql-objects/count-statement.d.ts} +3 -3
- package/esm/sql-objects/count-statement.js +31 -0
- package/{dist/sql-objects/Expression.d.ts → esm/sql-objects/expression.d.ts} +2 -2
- package/esm/sql-objects/expression.js +6 -0
- package/{dist/sql-objects/FieldExpression.d.ts → esm/sql-objects/field-expression.d.ts} +3 -3
- package/esm/sql-objects/field-expression.js +50 -0
- package/{dist/sql-objects/GroupColumn.d.ts → esm/sql-objects/group-column.d.ts} +3 -3
- package/esm/sql-objects/group-column.js +34 -0
- package/{dist/sql-objects/JoinStatement.d.ts → esm/sql-objects/join-statement.d.ts} +7 -7
- package/esm/sql-objects/join-statement.js +79 -0
- package/{dist/sql-objects/LowerStatement.d.ts → esm/sql-objects/lower-statement.d.ts} +3 -3
- package/esm/sql-objects/lower-statement.js +37 -0
- package/esm/sql-objects/max-statement.d.ts +22 -0
- package/esm/sql-objects/max-statement.js +37 -0
- package/esm/sql-objects/min-statement.d.ts +22 -0
- package/esm/sql-objects/min-statement.js +37 -0
- package/{dist/sql-objects/Operator.d.ts → esm/sql-objects/operator.d.ts} +2 -2
- package/esm/sql-objects/operator.js +3 -0
- package/{dist/sql-objects/operators/CompOperator.d.ts → esm/sql-objects/operators/comp-operator.d.ts} +4 -4
- package/esm/sql-objects/operators/comp-operator.js +86 -0
- package/{dist/sql-objects/operators/LogicalOperator.d.ts → esm/sql-objects/operators/logical-operator.d.ts} +4 -4
- package/esm/sql-objects/operators/logical-operator.js +79 -0
- package/esm/sql-objects/operators/op-and.d.ts +5 -0
- package/esm/sql-objects/operators/op-and.js +5 -0
- package/{dist/sql-objects/operators/OpBetween.d.ts → esm/sql-objects/operators/op-between.d.ts} +4 -4
- package/esm/sql-objects/operators/op-between.js +31 -0
- package/{dist/sql-objects/operators/OpEq.d.ts → esm/sql-objects/operators/op-eq.d.ts} +3 -3
- package/esm/sql-objects/operators/op-eq.js +9 -0
- package/{dist/sql-objects/operators/OpExists.d.ts → esm/sql-objects/operators/op-exists.d.ts} +4 -4
- package/esm/sql-objects/operators/op-exists.js +26 -0
- package/{dist/sql-objects/operators/OpGt.d.ts → esm/sql-objects/operators/op-gt.d.ts} +3 -3
- package/esm/sql-objects/operators/op-gt.js +9 -0
- package/{dist/sql-objects/operators/OpGte.d.ts → esm/sql-objects/operators/op-gte.d.ts} +3 -3
- package/esm/sql-objects/operators/op-gte.js +9 -0
- package/{dist/sql-objects/operators/OpILike.d.ts → esm/sql-objects/operators/op-ilike.d.ts} +2 -2
- package/esm/sql-objects/operators/op-ilike.js +6 -0
- package/{dist/sql-objects/operators/OpIn.d.ts → esm/sql-objects/operators/op-in.d.ts} +3 -3
- package/esm/sql-objects/operators/op-in.js +15 -0
- package/{dist/sql-objects/operators/OpIsNot.d.ts → esm/sql-objects/operators/op-is-not.d.ts} +3 -3
- package/esm/sql-objects/operators/op-is-not.js +9 -0
- package/{dist/sql-objects/operators/OpIs.d.ts → esm/sql-objects/operators/op-is.d.ts} +3 -3
- package/esm/sql-objects/operators/op-is.js +9 -0
- package/{dist/sql-objects/operators/OpLike.d.ts → esm/sql-objects/operators/op-like.d.ts} +4 -4
- package/esm/sql-objects/operators/op-like.js +18 -0
- package/{dist/sql-objects/operators/OpLt.d.ts → esm/sql-objects/operators/op-lt.d.ts} +3 -3
- package/esm/sql-objects/operators/op-lt.js +9 -0
- package/{dist/sql-objects/operators/OpLte.d.ts → esm/sql-objects/operators/op-lte.d.ts} +3 -3
- package/esm/sql-objects/operators/op-lte.js +9 -0
- package/{dist/sql-objects/operators/OpNe.d.ts → esm/sql-objects/operators/op-ne.d.ts} +3 -3
- package/esm/sql-objects/operators/op-ne.js +9 -0
- package/{dist/sql-objects/operators/OpNotBetween.d.ts → esm/sql-objects/operators/op-not-between.d.ts} +2 -2
- package/esm/sql-objects/operators/op-not-between.js +6 -0
- package/{dist/sql-objects/operators/OpNotExists.d.ts → esm/sql-objects/operators/op-not-exists.d.ts} +2 -2
- package/esm/sql-objects/operators/op-not-exists.js +6 -0
- package/{dist/sql-objects/operators/OpNotILike.d.ts → esm/sql-objects/operators/op-not-ilike.d.ts} +2 -2
- package/esm/sql-objects/operators/op-not-ilike.js +6 -0
- package/{dist/sql-objects/operators/OpNotIn.d.ts → esm/sql-objects/operators/op-not-in.d.ts} +2 -2
- package/esm/sql-objects/operators/op-not-in.js +6 -0
- package/{dist/sql-objects/operators/OpNotLike.d.ts → esm/sql-objects/operators/op-not-like.d.ts} +2 -2
- package/esm/sql-objects/operators/op-not-like.js +6 -0
- package/esm/sql-objects/operators/op-or.d.ts +5 -0
- package/esm/sql-objects/operators/op-or.js +5 -0
- package/{dist/sql-objects/OrderColumn.d.ts → esm/sql-objects/order-column.d.ts} +3 -3
- package/esm/sql-objects/order-column.js +39 -0
- package/{dist/sql-objects/ParamExpression.d.ts → esm/sql-objects/param-expression.d.ts} +3 -3
- package/esm/sql-objects/param-expression.js +52 -0
- package/{dist/sql-objects/RawStatement.d.ts → esm/sql-objects/raw-statement.d.ts} +3 -3
- package/esm/sql-objects/raw-statement.js +15 -0
- package/{dist/sql-objects/ReturningColumn.d.ts → esm/sql-objects/returning-column.d.ts} +3 -3
- package/esm/sql-objects/returning-column.js +29 -0
- package/esm/sql-objects/sequence-getter-statement.d.ts +24 -0
- package/esm/sql-objects/sequence-getter-statement.js +47 -0
- package/{dist/sql-objects/StringAggStatement.d.ts → esm/sql-objects/string-agg-statement.d.ts} +4 -4
- package/{dist/sql-objects/StringAggStatement.js → esm/sql-objects/string-agg-statement.js} +15 -15
- package/{dist/sql-objects/TableName.d.ts → esm/sql-objects/table-name.d.ts} +3 -3
- package/esm/sql-objects/table-name.js +30 -0
- package/{dist/sql-objects/UpperStatement.d.ts → esm/sql-objects/upper-statement.d.ts} +3 -3
- package/esm/sql-objects/upper-statement.js +37 -0
- package/{dist → esm}/sqlobject.initializers.d.ts +23 -16
- package/esm/sqlobject.initializers.js +101 -0
- package/{dist → esm}/typeguards.d.ts +17 -17
- package/esm/typeguards.js +57 -0
- package/{dist → esm}/types.d.ts +2 -2
- package/esm/types.js +1 -0
- package/package.json +49 -34
- package/dist/classes.d.ts +0 -38
- package/dist/classes.js +0 -41
- package/dist/index.d.ts +0 -20
- package/dist/index.js +0 -27
- package/dist/sql-objects/BaseField.js +0 -11
- package/dist/sql-objects/Expression.js +0 -7
- package/dist/sql-objects/operators/OpAnd.d.ts +0 -5
- package/dist/sql-objects/operators/OpAnd.js +0 -12
- package/dist/sql-objects/operators/OpEq.js +0 -13
- package/dist/sql-objects/operators/OpGt.js +0 -13
- package/dist/sql-objects/operators/OpGte.js +0 -13
- package/dist/sql-objects/operators/OpILike.js +0 -13
- package/dist/sql-objects/operators/OpIn.js +0 -19
- package/dist/sql-objects/operators/OpIs.js +0 -13
- package/dist/sql-objects/operators/OpIsNot.js +0 -13
- package/dist/sql-objects/operators/OpLt.js +0 -13
- package/dist/sql-objects/operators/OpLte.js +0 -13
- package/dist/sql-objects/operators/OpNe.js +0 -13
- package/dist/sql-objects/operators/OpNotBetween.js +0 -13
- package/dist/sql-objects/operators/OpNotExists.js +0 -13
- package/dist/sql-objects/operators/OpNotILike.js +0 -13
- package/dist/sql-objects/operators/OpNotIn.js +0 -13
- package/dist/sql-objects/operators/OpNotLike.js +0 -13
- package/dist/sql-objects/operators/OpOr.d.ts +0 -5
- package/dist/sql-objects/operators/OpOr.js +0 -12
- package/dist/sqlobject.initializers.js +0 -110
package/{dist/sql-objects/operators/OpExists.d.ts → esm/sql-objects/operators/op-exists.d.ts}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { SelectQuery } from '../../query/
|
|
3
|
-
import { SerializeContext } from '../../
|
|
4
|
-
import { CompOperator } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { SelectQuery } from '../../query/select-query.js';
|
|
3
|
+
import { SerializeContext } from '../../serialize-context.js';
|
|
4
|
+
import { CompOperator } from './comp-operator.js';
|
|
5
5
|
export declare class OpExists extends CompOperator {
|
|
6
6
|
_operatorType: OperatorType;
|
|
7
7
|
_symbol: string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { isSelectQuery } from '../../typeguards.js';
|
|
3
|
+
import { CompOperator } from './comp-operator.js';
|
|
4
|
+
export class OpExists extends CompOperator {
|
|
5
|
+
_operatorType = OperatorType.exists;
|
|
6
|
+
_symbol = 'exists';
|
|
7
|
+
constructor(query) {
|
|
8
|
+
super(query);
|
|
9
|
+
if (!(typeof query === 'object' && isSelectQuery(query)))
|
|
10
|
+
throw new TypeError('You must provide a SelectQuery in `exists()`');
|
|
11
|
+
}
|
|
12
|
+
_serialize(ctx) {
|
|
13
|
+
const left = this.__serializeItem(ctx, this._left);
|
|
14
|
+
if (this._isArray)
|
|
15
|
+
left.isArray = true;
|
|
16
|
+
const o = {
|
|
17
|
+
operatorType: this._operatorType,
|
|
18
|
+
symbol: this._symbol,
|
|
19
|
+
left
|
|
20
|
+
};
|
|
21
|
+
return this.__serialize(ctx, o);
|
|
22
|
+
}
|
|
23
|
+
__defaultSerialize(ctx, o) {
|
|
24
|
+
return o.left.expression ? o.symbol + ' ' + o.left.expression : '';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { Serializable } from '../../
|
|
3
|
-
import { CompOperator } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { Serializable } from '../../serializable.js';
|
|
3
|
+
import { CompOperator } from './comp-operator.js';
|
|
4
4
|
export declare class OpGt extends CompOperator {
|
|
5
5
|
_operatorType: OperatorType;
|
|
6
6
|
_symbol: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { Serializable } from '../../
|
|
3
|
-
import { CompOperator } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { Serializable } from '../../serializable.js';
|
|
3
|
+
import { CompOperator } from './comp-operator.js';
|
|
4
4
|
export declare class OpGte extends CompOperator {
|
|
5
5
|
_operatorType: OperatorType;
|
|
6
6
|
_symbol: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { OpLike } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { OpLike } from './op-like.js';
|
|
3
3
|
export declare class OpILike extends OpLike {
|
|
4
4
|
_operatorType: OperatorType;
|
|
5
5
|
_symbol: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { SerializeContext } from '../../
|
|
3
|
-
import { CompOperator } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { SerializeContext } from '../../serialize-context.js';
|
|
3
|
+
import { CompOperator } from './comp-operator.js';
|
|
4
4
|
export declare class OpIn extends CompOperator {
|
|
5
5
|
_operatorType: OperatorType;
|
|
6
6
|
_symbol: string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { isSerializable } from '../../typeguards.js';
|
|
3
|
+
import { CompOperator } from './comp-operator.js';
|
|
4
|
+
export class OpIn extends CompOperator {
|
|
5
|
+
_operatorType = OperatorType.in;
|
|
6
|
+
_symbol = 'in';
|
|
7
|
+
constructor(left, right) {
|
|
8
|
+
super(left, Array.isArray(right) || isSerializable(right) ? right : [right]);
|
|
9
|
+
}
|
|
10
|
+
_serialize(ctx) {
|
|
11
|
+
if (Array.isArray(this._right) && !this._right.length)
|
|
12
|
+
return '';
|
|
13
|
+
return super._serialize(ctx);
|
|
14
|
+
}
|
|
15
|
+
}
|
package/{dist/sql-objects/operators/OpIsNot.d.ts → esm/sql-objects/operators/op-is-not.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { Serializable } from '../../
|
|
3
|
-
import { CompOperator } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { Serializable } from '../../serializable.js';
|
|
3
|
+
import { CompOperator } from './comp-operator.js';
|
|
4
4
|
export declare class OpIsNot extends CompOperator {
|
|
5
5
|
_operatorType: OperatorType;
|
|
6
6
|
_symbol: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { CompOperator } from './comp-operator.js';
|
|
3
|
+
export class OpIsNot extends CompOperator {
|
|
4
|
+
_operatorType = OperatorType.isNot;
|
|
5
|
+
_symbol = 'is not';
|
|
6
|
+
constructor(left, right) {
|
|
7
|
+
super(left, right);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { Serializable } from '../../
|
|
3
|
-
import { CompOperator } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { Serializable } from '../../serializable.js';
|
|
3
|
+
import { CompOperator } from './comp-operator.js';
|
|
4
4
|
export declare class OpIs extends CompOperator {
|
|
5
5
|
_operatorType: OperatorType;
|
|
6
6
|
_symbol: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { Serializable } from '../../
|
|
3
|
-
import { SerializeContext } from '../../
|
|
4
|
-
import { CompOperator } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { Serializable } from '../../serializable.js';
|
|
3
|
+
import { SerializeContext } from '../../serialize-context.js';
|
|
4
|
+
import { CompOperator } from './comp-operator.js';
|
|
5
5
|
export declare class OpLike extends CompOperator {
|
|
6
6
|
_operatorType: OperatorType;
|
|
7
7
|
_symbol: string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { isSerializable } from '../../typeguards.js';
|
|
3
|
+
import { CompOperator } from './comp-operator.js';
|
|
4
|
+
export class OpLike extends CompOperator {
|
|
5
|
+
_operatorType = OperatorType.like;
|
|
6
|
+
_symbol = 'like';
|
|
7
|
+
constructor(left, right) {
|
|
8
|
+
super(left, right);
|
|
9
|
+
}
|
|
10
|
+
__serialize(ctx, o) {
|
|
11
|
+
if (o.right && typeof o.right !== 'string' && !isSerializable(o.right))
|
|
12
|
+
o.right = ctx.anyToSQL(o.right);
|
|
13
|
+
if (!o.right)
|
|
14
|
+
return '';
|
|
15
|
+
o.right = ctx.anyToSQL(o.right);
|
|
16
|
+
return ctx.serialize(this._type, o, (_ctx, _o) => this.__defaultSerialize(_ctx, _o));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { Serializable } from '../../
|
|
3
|
-
import { CompOperator } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { Serializable } from '../../serializable.js';
|
|
3
|
+
import { CompOperator } from './comp-operator.js';
|
|
4
4
|
export declare class OpLt extends CompOperator {
|
|
5
5
|
_operatorType: OperatorType;
|
|
6
6
|
_symbol: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { Serializable } from '../../
|
|
3
|
-
import { CompOperator } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { Serializable } from '../../serializable.js';
|
|
3
|
+
import { CompOperator } from './comp-operator.js';
|
|
4
4
|
export declare class OpLte extends CompOperator {
|
|
5
5
|
_operatorType: OperatorType;
|
|
6
6
|
_symbol: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { Serializable } from '../../
|
|
3
|
-
import { CompOperator } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { Serializable } from '../../serializable.js';
|
|
3
|
+
import { CompOperator } from './comp-operator.js';
|
|
4
4
|
export declare class OpNe extends CompOperator {
|
|
5
5
|
_operatorType: OperatorType;
|
|
6
6
|
_symbol: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { OpBetween } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { OpBetween } from './op-between.js';
|
|
3
3
|
export declare class OpNotBetween extends OpBetween {
|
|
4
4
|
_operatorType: OperatorType;
|
|
5
5
|
_symbol: string;
|
package/{dist/sql-objects/operators/OpNotExists.d.ts → esm/sql-objects/operators/op-not-exists.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { OpExists } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { OpExists } from './op-exists.js';
|
|
3
3
|
export declare class OpNotExists extends OpExists {
|
|
4
4
|
_operatorType: OperatorType;
|
|
5
5
|
_symbol: string;
|
package/{dist/sql-objects/operators/OpNotILike.d.ts → esm/sql-objects/operators/op-not-ilike.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { OpILike } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { OpILike } from './op-ilike.js';
|
|
3
3
|
export declare class OpNotILike extends OpILike {
|
|
4
4
|
_operatorType: OperatorType;
|
|
5
5
|
_symbol: string;
|
package/{dist/sql-objects/operators/OpNotLike.d.ts → esm/sql-objects/operators/op-not-like.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums';
|
|
2
|
-
import { OpLike } from './
|
|
1
|
+
import { OperatorType } from '../../enums.js';
|
|
2
|
+
import { OpLike } from './op-like.js';
|
|
3
3
|
export declare class OpNotLike extends OpLike {
|
|
4
4
|
_operatorType: OperatorType;
|
|
5
5
|
_symbol: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SerializationType } from '../enums';
|
|
2
|
-
import { SerializeContext } from '../
|
|
3
|
-
import { BaseField } from './
|
|
1
|
+
import { SerializationType } from '../enums.js';
|
|
2
|
+
import { SerializeContext } from '../serialize-context.js';
|
|
3
|
+
import { BaseField } from './base-field.js';
|
|
4
4
|
export declare class OrderColumn extends BaseField {
|
|
5
5
|
_descending?: boolean;
|
|
6
6
|
constructor(value: string);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SerializationType } from '../enums.js';
|
|
2
|
+
import { BaseField } from './base-field.js';
|
|
3
|
+
const ORDER_COLUMN_PATTERN = /^([-+])?((?:[a-zA-Z][\w$]*\.){0,2})([a-zA-Z][\w$]*|\*) *(asc|dsc|desc|ascending|descending)?$/i;
|
|
4
|
+
export class OrderColumn extends BaseField {
|
|
5
|
+
_descending;
|
|
6
|
+
constructor(value) {
|
|
7
|
+
super();
|
|
8
|
+
const m = value.match(ORDER_COLUMN_PATTERN);
|
|
9
|
+
if (!m)
|
|
10
|
+
throw new TypeError(`"${value}" does not match order column format`);
|
|
11
|
+
this._field = m[3];
|
|
12
|
+
if (m[2]) {
|
|
13
|
+
const a = m[2].split(/\./g);
|
|
14
|
+
a.pop();
|
|
15
|
+
this._table = a.pop();
|
|
16
|
+
this._schema = a.pop();
|
|
17
|
+
}
|
|
18
|
+
this._descending = !!((m[1] === '-') ||
|
|
19
|
+
(!m[1] && m[4] && ['dsc', 'desc', 'descending'].includes(m[4].toLowerCase())));
|
|
20
|
+
}
|
|
21
|
+
get _type() {
|
|
22
|
+
return SerializationType.ORDER_COLUMN;
|
|
23
|
+
}
|
|
24
|
+
_serialize(ctx) {
|
|
25
|
+
const o = {
|
|
26
|
+
schema: this._schema,
|
|
27
|
+
table: this._table,
|
|
28
|
+
field: this._field,
|
|
29
|
+
descending: !!this._descending,
|
|
30
|
+
isReservedWord: !!(this._field && ctx.isReservedWord(this._field))
|
|
31
|
+
};
|
|
32
|
+
return ctx.serialize(this._type, o, () => {
|
|
33
|
+
return (o.schema ? o.schema + '.' : '') +
|
|
34
|
+
(o.table ? o.table + '.' : '') +
|
|
35
|
+
(o.isReservedWord ? '"' + o.field + '"' : o.field) +
|
|
36
|
+
(o.descending ? ' desc' : '');
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DataType, SerializationType } from '../enums';
|
|
2
|
-
import { Serializable } from '../
|
|
3
|
-
import { SerializeContext } from '../
|
|
1
|
+
import { DataType, SerializationType } from '../enums.js';
|
|
2
|
+
import { Serializable } from '../serializable.js';
|
|
3
|
+
import { SerializeContext } from '../serialize-context.js';
|
|
4
4
|
export declare class ParamExpression extends Serializable {
|
|
5
5
|
_name: string;
|
|
6
6
|
_dataType?: DataType;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { SerializationType } from '../enums.js';
|
|
2
|
+
import { Serializable } from '../serializable.js';
|
|
3
|
+
export class ParamExpression extends Serializable {
|
|
4
|
+
_name;
|
|
5
|
+
_dataType;
|
|
6
|
+
_isArray;
|
|
7
|
+
constructor(arg) {
|
|
8
|
+
super();
|
|
9
|
+
if (typeof arg === 'object') {
|
|
10
|
+
this._name = arg.name;
|
|
11
|
+
this._dataType = arg.dataType;
|
|
12
|
+
this._isArray = arg.isArray;
|
|
13
|
+
}
|
|
14
|
+
else
|
|
15
|
+
this._name = arg;
|
|
16
|
+
}
|
|
17
|
+
get _type() {
|
|
18
|
+
return SerializationType.EXTERNAL_PARAMETER;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Performs serialization
|
|
22
|
+
*/
|
|
23
|
+
_serialize(ctx) {
|
|
24
|
+
const o = {
|
|
25
|
+
name: this._name,
|
|
26
|
+
dataType: this._dataType,
|
|
27
|
+
isArray: this._isArray,
|
|
28
|
+
};
|
|
29
|
+
return ctx.serialize(this._type, o, () => this.__defaultSerialize(ctx, o));
|
|
30
|
+
}
|
|
31
|
+
__defaultSerialize(ctx, o) {
|
|
32
|
+
let prmValue = (ctx.params && ctx.params[o.name]) ?? null;
|
|
33
|
+
if (prmValue != null && o.isArray && !Array.isArray(prmValue))
|
|
34
|
+
prmValue = [prmValue];
|
|
35
|
+
ctx.preparedParams = ctx.preparedParams || {};
|
|
36
|
+
if (Array.isArray(ctx.preparedParams))
|
|
37
|
+
ctx.preparedParams.push(prmValue);
|
|
38
|
+
else
|
|
39
|
+
ctx.preparedParams[o.name] = prmValue;
|
|
40
|
+
const paramOps = {
|
|
41
|
+
dataType: this._dataType,
|
|
42
|
+
isArray: this._isArray,
|
|
43
|
+
};
|
|
44
|
+
ctx.paramOptions = ctx.paramOptions ||
|
|
45
|
+
(Array.isArray(ctx.preparedParams) ? [] : {});
|
|
46
|
+
if (Array.isArray(ctx.paramOptions))
|
|
47
|
+
ctx.paramOptions.push(paramOps);
|
|
48
|
+
else
|
|
49
|
+
ctx.paramOptions[o.name] = paramOps;
|
|
50
|
+
return ':' + o.name;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SerializationType } from '../enums';
|
|
2
|
-
import { Serializable } from '../
|
|
3
|
-
import { SerializeContext } from '../
|
|
1
|
+
import { SerializationType } from '../enums.js';
|
|
2
|
+
import { Serializable } from '../serializable.js';
|
|
3
|
+
import { SerializeContext } from '../serialize-context.js';
|
|
4
4
|
export declare class RawStatement extends Serializable {
|
|
5
5
|
_text: string;
|
|
6
6
|
constructor(str: string);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SerializationType } from '../enums.js';
|
|
2
|
+
import { Serializable } from '../serializable.js';
|
|
3
|
+
export class RawStatement extends Serializable {
|
|
4
|
+
_text;
|
|
5
|
+
constructor(str) {
|
|
6
|
+
super();
|
|
7
|
+
this._text = str;
|
|
8
|
+
}
|
|
9
|
+
get _type() {
|
|
10
|
+
return SerializationType.RAW;
|
|
11
|
+
}
|
|
12
|
+
_serialize(ctx) {
|
|
13
|
+
return ctx.serialize(this._type, this._text, () => this._text);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SerializationType } from '../enums';
|
|
2
|
-
import { SerializeContext } from '../
|
|
3
|
-
import { BaseField } from './
|
|
1
|
+
import { SerializationType } from '../enums.js';
|
|
2
|
+
import { SerializeContext } from '../serialize-context.js';
|
|
3
|
+
import { BaseField } from './base-field.js';
|
|
4
4
|
export declare class ReturningColumn extends BaseField {
|
|
5
5
|
_alias: string;
|
|
6
6
|
constructor(field: string);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SerializationType } from '../enums.js';
|
|
2
|
+
import { BaseField } from './base-field.js';
|
|
3
|
+
const RETURNING_COLUMN_PATTERN = /^([a-zA-Z]\w*) *(?:as)? *(\w+)?$/;
|
|
4
|
+
export class ReturningColumn extends BaseField {
|
|
5
|
+
_alias;
|
|
6
|
+
constructor(field) {
|
|
7
|
+
super();
|
|
8
|
+
const m = field.match(RETURNING_COLUMN_PATTERN);
|
|
9
|
+
if (!m)
|
|
10
|
+
throw new TypeError(`"${field}" does not match returning column format`);
|
|
11
|
+
this._field = m[1];
|
|
12
|
+
this._alias = m[2];
|
|
13
|
+
}
|
|
14
|
+
get _type() {
|
|
15
|
+
return SerializationType.RETURNING_COLUMN;
|
|
16
|
+
}
|
|
17
|
+
_serialize(ctx) {
|
|
18
|
+
const o = {
|
|
19
|
+
field: this._field,
|
|
20
|
+
alias: this._alias
|
|
21
|
+
};
|
|
22
|
+
ctx.returningFields = ctx.returningFields || [];
|
|
23
|
+
ctx.returningFields.push(o);
|
|
24
|
+
return ctx.serialize(this._type, o, () => {
|
|
25
|
+
return ctx.escapeReserved(o.field) +
|
|
26
|
+
(o.alias ? ' as ' + ctx.escapeReserved(o.alias) : '');
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SerializationType } from '../enums.js';
|
|
2
|
+
import { Serializable } from '../serializable.js';
|
|
3
|
+
import { SerializeContext } from '../serialize-context.js';
|
|
4
|
+
export declare class SequenceGetterStatement extends Serializable {
|
|
5
|
+
_expression: string;
|
|
6
|
+
_next: boolean;
|
|
7
|
+
_alias?: string;
|
|
8
|
+
constructor(expression: string, next?: boolean);
|
|
9
|
+
get _type(): SerializationType;
|
|
10
|
+
next(value: boolean): this;
|
|
11
|
+
/**
|
|
12
|
+
* Sets alias to case expression.
|
|
13
|
+
*/
|
|
14
|
+
as(alias: string): this;
|
|
15
|
+
/**
|
|
16
|
+
* Performs serialization
|
|
17
|
+
*
|
|
18
|
+
* @param {Object} ctx
|
|
19
|
+
* @return {string}
|
|
20
|
+
* @override
|
|
21
|
+
*/
|
|
22
|
+
_serialize(ctx: SerializeContext): string;
|
|
23
|
+
protected __defaultSerialize(ctx: SerializeContext, o: any): string;
|
|
24
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SerializationType } from '../enums.js';
|
|
2
|
+
import { Serializable } from '../serializable.js';
|
|
3
|
+
export class SequenceGetterStatement extends Serializable {
|
|
4
|
+
_expression;
|
|
5
|
+
_next;
|
|
6
|
+
_alias;
|
|
7
|
+
constructor(expression, next) {
|
|
8
|
+
super();
|
|
9
|
+
this._expression = expression;
|
|
10
|
+
this._next = !!next;
|
|
11
|
+
}
|
|
12
|
+
get _type() {
|
|
13
|
+
return SerializationType.SEQUENCE_GETTER_STATEMENT;
|
|
14
|
+
}
|
|
15
|
+
next(value) {
|
|
16
|
+
this._next = value;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Sets alias to case expression.
|
|
21
|
+
*/
|
|
22
|
+
as(alias) {
|
|
23
|
+
this._alias = alias;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Performs serialization
|
|
28
|
+
*
|
|
29
|
+
* @param {Object} ctx
|
|
30
|
+
* @return {string}
|
|
31
|
+
* @override
|
|
32
|
+
*/
|
|
33
|
+
_serialize(ctx) {
|
|
34
|
+
if (!this._expression)
|
|
35
|
+
return '';
|
|
36
|
+
const q = {
|
|
37
|
+
genName: this._expression,
|
|
38
|
+
next: this._next,
|
|
39
|
+
alias: this._alias
|
|
40
|
+
};
|
|
41
|
+
return ctx.serialize(this._type, q, () => this.__defaultSerialize(ctx, q));
|
|
42
|
+
}
|
|
43
|
+
__defaultSerialize(ctx, o) {
|
|
44
|
+
return (o.next ? 'nextval' : 'currval') + '(\'' + o.genName + '\')' +
|
|
45
|
+
(o.alias ? ' ' + o.alias : '');
|
|
46
|
+
}
|
|
47
|
+
}
|