@sqb/builder 4.26.1 → 5.0.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/index.d.ts +4 -14
- package/index.js +4 -14
- package/op.ns.d.ts +64 -0
- package/op.ns.js +65 -0
- package/package.json +1 -1
- package/serializable.d.ts +12 -3
- package/serializable.js +9 -2
- package/serialize-context.d.ts +2 -2
- package/serialize-context.js +3 -3
- package/{query/delete-query.d.ts → sql/delete.d.ts} +14 -6
- package/{query/delete-query.js → sql/delete.js} +24 -20
- package/sql/elements/base-field.d.ts +18 -0
- package/sql/elements/base-field.js +12 -0
- package/{sql-objects/case-statement.d.ts → sql/elements/case.d.ts} +18 -10
- package/{sql-objects/case-statement.js → sql/elements/case.js} +13 -9
- package/sql/elements/coalesce.d.ts +30 -0
- package/{sql-objects/coalesce-statement.js → sql/elements/coalesce.js} +11 -7
- package/sql/elements/count.d.ts +29 -0
- package/{sql-objects/count-statement.js → sql/elements/count.js} +10 -3
- package/sql/elements/field.d.ts +27 -0
- package/sql/elements/field.js +54 -0
- package/sql/elements/group-column.d.ts +16 -0
- package/{sql-objects → sql/elements}/group-column.js +19 -15
- package/sql/elements/index.d.ts +26 -0
- package/sql/elements/index.js +26 -0
- package/sql/elements/join-cross.d.ts +15 -0
- package/sql/elements/join-cross.js +11 -0
- package/sql/elements/join-full-outer.d.ts +15 -0
- package/sql/elements/join-full-outer.js +11 -0
- package/sql/elements/join-inner.d.ts +15 -0
- package/sql/elements/join-inner.js +11 -0
- package/sql/elements/join-left-outer.d.ts +15 -0
- package/sql/elements/join-left-outer.js +11 -0
- package/sql/elements/join-left.d.ts +15 -0
- package/sql/elements/join-left.js +11 -0
- package/sql/elements/join-outer.d.ts +15 -0
- package/sql/elements/join-outer.js +11 -0
- package/sql/elements/join-right-outer.d.ts +15 -0
- package/sql/elements/join-right-outer.js +11 -0
- package/sql/elements/join-right.d.ts +15 -0
- package/sql/elements/join-right.js +11 -0
- package/sql/elements/join.d.ts +25 -0
- package/{sql-objects/join-statement.js → sql/elements/join.js} +24 -19
- package/sql/elements/lower.d.ts +30 -0
- package/{sql-objects/lower-statement.js → sql/elements/lower.js} +11 -7
- package/{sql-objects/min-statement.d.ts → sql/elements/max.d.ts} +13 -5
- package/{sql-objects/max-statement.js → sql/elements/max.js} +11 -7
- package/{sql-objects/lower-statement.d.ts → sql/elements/min.d.ts} +13 -4
- package/{sql-objects/min-statement.js → sql/elements/min.js} +10 -3
- package/sql/elements/order-column.d.ts +17 -0
- package/sql/elements/order-column.js +43 -0
- package/sql/elements/param.d.ts +36 -0
- package/{sql-objects/param-expression.js → sql/elements/param.js} +26 -13
- package/sql/elements/raw.d.ts +17 -0
- package/sql/elements/raw.js +19 -0
- package/sql/elements/returning-column.d.ts +17 -0
- package/sql/elements/returning-column.js +32 -0
- package/sql/elements/sequence.d.ts +32 -0
- package/{sql-objects/sequence-getter-statement.js → sql/elements/sequence.js} +12 -8
- package/sql/elements/string-agg.d.ts +39 -0
- package/{sql-objects/string-agg-statement.js → sql/elements/string-agg.js} +15 -12
- package/sql/elements/table-name.d.ts +32 -0
- package/sql/elements/table-name.js +59 -0
- package/sql/elements/upper.d.ts +30 -0
- package/{sql-objects/upper-statement.js → sql/elements/upper.js} +11 -7
- package/sql/index.d.ts +9 -0
- package/sql/index.js +9 -0
- package/sql/insert.d.ts +37 -0
- package/{query/insert-query.js → sql/insert.js} +33 -18
- package/sql/operators/and.d.ts +14 -0
- package/sql/operators/and.js +13 -0
- package/sql/operators/between.d.ts +18 -0
- package/{sql-objects/operators/op-between.js → sql/operators/between.js} +20 -8
- package/sql/operators/comp-operator.d.ts +24 -0
- package/{sql-objects → sql}/operators/comp-operator.js +30 -24
- package/sql/operators/eq.d.ts +13 -0
- package/sql/operators/eq.js +23 -0
- package/sql/operators/exists.d.ts +17 -0
- package/sql/operators/exists.js +31 -0
- package/sql/operators/gt.d.ts +13 -0
- package/sql/operators/gt.js +20 -0
- package/sql/operators/gte.d.ts +13 -0
- package/sql/operators/gte.js +20 -0
- package/sql/operators/i-like.d.ts +13 -0
- package/sql/operators/i-like.js +21 -0
- package/sql/operators/in.d.ts +15 -0
- package/sql/operators/in.js +27 -0
- package/sql/operators/index.d.ts +24 -0
- package/sql/operators/index.js +24 -0
- package/sql/operators/is-not.d.ts +13 -0
- package/sql/operators/is-not.js +13 -0
- package/sql/operators/is.d.ts +13 -0
- package/sql/operators/is.js +20 -0
- package/sql/operators/like.d.ts +15 -0
- package/sql/operators/like.js +27 -0
- package/sql/operators/logical-operator.d.ts +15 -0
- package/sql/operators/logical-operator.js +86 -0
- package/sql/operators/lt.d.ts +13 -0
- package/sql/operators/lt.js +20 -0
- package/sql/operators/lte.d.ts +13 -0
- package/sql/operators/lte.js +20 -0
- package/sql/operators/ne.d.ts +13 -0
- package/sql/operators/ne.js +20 -0
- package/sql/operators/not-between.d.ts +15 -0
- package/sql/operators/not-between.js +13 -0
- package/sql/operators/not-exists.d.ts +14 -0
- package/sql/operators/not-exists.js +13 -0
- package/sql/operators/not-i-like.d.ts +13 -0
- package/sql/operators/not-i-like.js +13 -0
- package/sql/operators/not-in.d.ts +13 -0
- package/sql/operators/not-in.js +13 -0
- package/sql/operators/not-like.d.ts +13 -0
- package/sql/operators/not-like.js +13 -0
- package/sql/operators/not.d.ts +18 -0
- package/sql/operators/not.js +20 -0
- package/sql/operators/operator.d.ts +12 -0
- package/sql/operators/operator.js +11 -0
- package/sql/operators/or.d.ts +12 -0
- package/sql/operators/or.js +12 -0
- package/sql/query.d.ts +31 -0
- package/{query → sql}/query.js +14 -8
- package/sql/returning-query.d.ts +23 -0
- package/{query → sql}/returning-query.js +13 -3
- package/{query/select-query.d.ts → sql/select.d.ts} +29 -21
- package/{query/select-query.js → sql/select.js} +21 -17
- package/{query/union-query.d.ts → sql/union.d.ts} +10 -2
- package/{query/union-query.js → sql/union.js} +10 -6
- package/sql/update.d.ts +38 -0
- package/{query/update-query.js → sql/update.js} +34 -25
- package/type-guards.d.ts +22 -0
- package/{typeguards.js → type-guards.js} +15 -11
- package/classes.ns.d.ts +0 -38
- package/classes.ns.js +0 -38
- package/op.initializers.d.ts +0 -89
- package/op.initializers.js +0 -131
- package/query/insert-query.d.ts +0 -23
- package/query/query.d.ts +0 -25
- package/query/returning-query.d.ts +0 -14
- package/query/update-query.d.ts +0 -29
- package/sql-objects/base-field.d.ts +0 -7
- package/sql-objects/base-field.js +0 -7
- package/sql-objects/coalesce-statement.d.ts +0 -22
- package/sql-objects/count-statement.d.ts +0 -20
- package/sql-objects/expression.d.ts +0 -7
- package/sql-objects/expression.js +0 -6
- package/sql-objects/field-expression.d.ts +0 -14
- package/sql-objects/field-expression.js +0 -50
- package/sql-objects/group-column.d.ts +0 -8
- package/sql-objects/join-statement.d.ts +0 -17
- package/sql-objects/max-statement.d.ts +0 -22
- package/sql-objects/operator.d.ts +0 -5
- package/sql-objects/operator.js +0 -3
- package/sql-objects/operators/comp-operator.d.ts +0 -16
- package/sql-objects/operators/logical-operator.d.ts +0 -16
- package/sql-objects/operators/logical-operator.js +0 -81
- package/sql-objects/operators/op-and.d.ts +0 -5
- package/sql-objects/operators/op-and.js +0 -5
- package/sql-objects/operators/op-between.d.ts +0 -11
- package/sql-objects/operators/op-eq.d.ts +0 -8
- package/sql-objects/operators/op-eq.js +0 -9
- package/sql-objects/operators/op-exists.d.ts +0 -11
- package/sql-objects/operators/op-exists.js +0 -27
- package/sql-objects/operators/op-gt.d.ts +0 -8
- package/sql-objects/operators/op-gt.js +0 -9
- package/sql-objects/operators/op-gte.d.ts +0 -8
- package/sql-objects/operators/op-gte.js +0 -9
- package/sql-objects/operators/op-ilike.d.ts +0 -6
- package/sql-objects/operators/op-ilike.js +0 -6
- package/sql-objects/operators/op-in.d.ts +0 -9
- package/sql-objects/operators/op-in.js +0 -15
- package/sql-objects/operators/op-is-not.d.ts +0 -8
- package/sql-objects/operators/op-is-not.js +0 -9
- package/sql-objects/operators/op-is.d.ts +0 -8
- package/sql-objects/operators/op-is.js +0 -9
- package/sql-objects/operators/op-like.d.ts +0 -10
- package/sql-objects/operators/op-like.js +0 -16
- package/sql-objects/operators/op-lt.d.ts +0 -8
- package/sql-objects/operators/op-lt.js +0 -9
- package/sql-objects/operators/op-lte.d.ts +0 -8
- package/sql-objects/operators/op-lte.js +0 -9
- package/sql-objects/operators/op-ne.d.ts +0 -8
- package/sql-objects/operators/op-ne.js +0 -9
- package/sql-objects/operators/op-not-between.d.ts +0 -6
- package/sql-objects/operators/op-not-between.js +0 -6
- package/sql-objects/operators/op-not-exists.d.ts +0 -6
- package/sql-objects/operators/op-not-exists.js +0 -6
- package/sql-objects/operators/op-not-ilike.d.ts +0 -6
- package/sql-objects/operators/op-not-ilike.js +0 -6
- package/sql-objects/operators/op-not-in.d.ts +0 -6
- package/sql-objects/operators/op-not-in.js +0 -6
- package/sql-objects/operators/op-not-like.d.ts +0 -6
- package/sql-objects/operators/op-not-like.js +0 -6
- package/sql-objects/operators/op-not.d.ts +0 -11
- package/sql-objects/operators/op-not.js +0 -17
- package/sql-objects/operators/op-or.d.ts +0 -5
- package/sql-objects/operators/op-or.js +0 -5
- package/sql-objects/order-column.d.ts +0 -9
- package/sql-objects/order-column.js +0 -39
- package/sql-objects/param-expression.d.ts +0 -23
- package/sql-objects/raw-statement.d.ts +0 -9
- package/sql-objects/raw-statement.js +0 -15
- package/sql-objects/returning-column.d.ts +0 -9
- package/sql-objects/returning-column.js +0 -27
- package/sql-objects/sequence-getter-statement.d.ts +0 -24
- package/sql-objects/string-agg-statement.d.ts +0 -31
- package/sql-objects/table-name.d.ts +0 -22
- package/sql-objects/table-name.js +0 -55
- package/sql-objects/upper-statement.d.ts +0 -22
- package/sqlobject.initializers.d.ts +0 -61
- package/sqlobject.initializers.js +0 -115
- package/typeguards.d.ts +0 -37
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SerializationType } from '../enums.js';
|
|
2
|
-
import { Serializable } from '../serializable.js';
|
|
3
|
-
import { SerializeContext } from '../serialize-context.js';
|
|
4
|
-
export declare class CoalesceStatement extends Serializable {
|
|
5
|
-
_expressions: any[];
|
|
6
|
-
_alias?: string;
|
|
7
|
-
constructor(...expressions: any[]);
|
|
8
|
-
get _type(): SerializationType;
|
|
9
|
-
/**
|
|
10
|
-
* Sets alias to case expression.
|
|
11
|
-
*/
|
|
12
|
-
as(alias: string): this;
|
|
13
|
-
/**
|
|
14
|
-
* Performs serialization
|
|
15
|
-
*
|
|
16
|
-
* @param {Object} ctx
|
|
17
|
-
* @return {string}
|
|
18
|
-
* @override
|
|
19
|
-
*/
|
|
20
|
-
_serialize(ctx: SerializeContext): string;
|
|
21
|
-
protected __defaultSerialize(ctx: SerializeContext, o: any): string;
|
|
22
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { SerializationType } from '../enums.js';
|
|
2
|
-
import { Serializable } from '../serializable.js';
|
|
3
|
-
import { SerializeContext } from '../serialize-context.js';
|
|
4
|
-
export declare class CountStatement extends Serializable {
|
|
5
|
-
_alias?: string;
|
|
6
|
-
get _type(): SerializationType;
|
|
7
|
-
/**
|
|
8
|
-
* Sets alias to case expression.
|
|
9
|
-
*/
|
|
10
|
-
as(alias: string): this;
|
|
11
|
-
/**
|
|
12
|
-
* Performs serialization
|
|
13
|
-
*
|
|
14
|
-
* @param {Object} ctx
|
|
15
|
-
* @return {string}
|
|
16
|
-
* @override
|
|
17
|
-
*/
|
|
18
|
-
_serialize(ctx: SerializeContext): string;
|
|
19
|
-
protected __defaultSerialize(ctx: SerializeContext, o: any): string;
|
|
20
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DataType, SerializationType } from '../enums.js';
|
|
2
|
-
import { SerializeContext } from '../serialize-context.js';
|
|
3
|
-
import { BaseField } from './base-field.js';
|
|
4
|
-
export declare class FieldExpression extends BaseField {
|
|
5
|
-
_alias?: string;
|
|
6
|
-
constructor(expression: string, dataType?: DataType, isArray?: boolean);
|
|
7
|
-
constructor(args: {
|
|
8
|
-
expression: string;
|
|
9
|
-
dataType?: DataType;
|
|
10
|
-
isArray?: boolean;
|
|
11
|
-
});
|
|
12
|
-
get _type(): SerializationType;
|
|
13
|
-
_serialize(ctx: SerializeContext): string;
|
|
14
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { SerializationType } from '../enums.js';
|
|
2
|
-
import { BaseField } from './base-field.js';
|
|
3
|
-
const TABLE_COLUMN_PATTERN = /^((?:[a-zA-Z_][\w$_]*\.){0,2}) *([0-9a-zA-Z_][\w$_]*|\*) *(?:as)? *([a-zA-Z_][\w$_]*)?$/;
|
|
4
|
-
export class FieldExpression extends BaseField {
|
|
5
|
-
_alias;
|
|
6
|
-
constructor(arg0, arg1, arg2) {
|
|
7
|
-
super();
|
|
8
|
-
let expression;
|
|
9
|
-
if (typeof arg0 === 'object') {
|
|
10
|
-
expression = arg0.expression;
|
|
11
|
-
this._dataType = arg0.dataType;
|
|
12
|
-
this._isArray = arg0.isArray;
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
expression = arg0;
|
|
16
|
-
this._dataType = arg1;
|
|
17
|
-
this._isArray = arg2;
|
|
18
|
-
}
|
|
19
|
-
const m = expression?.match(TABLE_COLUMN_PATTERN);
|
|
20
|
-
if (!m)
|
|
21
|
-
throw new TypeError(`"${expression}" does not match table column format`);
|
|
22
|
-
this._field = m[2];
|
|
23
|
-
if (m[1]) {
|
|
24
|
-
const a = m[1].split(/\./g);
|
|
25
|
-
a.pop();
|
|
26
|
-
this._table = a.pop();
|
|
27
|
-
this._schema = a.pop();
|
|
28
|
-
}
|
|
29
|
-
this._alias = this._field !== '*' ? m[3] : '';
|
|
30
|
-
}
|
|
31
|
-
get _type() {
|
|
32
|
-
return SerializationType.FIELD_NAME;
|
|
33
|
-
}
|
|
34
|
-
_serialize(ctx) {
|
|
35
|
-
const o = {
|
|
36
|
-
schema: this._schema,
|
|
37
|
-
table: this._table,
|
|
38
|
-
field: this._field,
|
|
39
|
-
alias: this._alias,
|
|
40
|
-
isReservedWord: !!(this._field && ctx.isReservedWord(this._field)),
|
|
41
|
-
};
|
|
42
|
-
return ctx.serialize(this._type, o, () => {
|
|
43
|
-
const prefix = ctx.escapeReserved(this._schema ? this._schema + '.' : '') +
|
|
44
|
-
(this._table ? this._table + '.' : '');
|
|
45
|
-
return (prefix +
|
|
46
|
-
(!prefix && o.isReservedWord ? '"' + this._field + '"' : this._field) +
|
|
47
|
-
(this._alias ? ' as ' + this._alias : ''));
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { SerializationType } from '../enums.js';
|
|
2
|
-
import { SerializeContext } from '../serialize-context.js';
|
|
3
|
-
import { BaseField } from './base-field.js';
|
|
4
|
-
export declare class GroupColumn extends BaseField {
|
|
5
|
-
constructor(value: string);
|
|
6
|
-
get _type(): SerializationType;
|
|
7
|
-
_serialize(ctx: SerializeContext): string;
|
|
8
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { JoinType, SerializationType } from '../enums.js';
|
|
2
|
-
import type { SelectQuery } from '../query/select-query.js';
|
|
3
|
-
import { Serializable } from '../serializable.js';
|
|
4
|
-
import type { SerializeContext } from '../serialize-context.js';
|
|
5
|
-
import type { LogicalOperator } from './operators/logical-operator.js';
|
|
6
|
-
import type { RawStatement } from './raw-statement.js';
|
|
7
|
-
import { TableName } from './table-name.js';
|
|
8
|
-
export declare class JoinStatement extends Serializable {
|
|
9
|
-
_joinType: JoinType;
|
|
10
|
-
_table: TableName | SelectQuery | RawStatement;
|
|
11
|
-
_conditions: LogicalOperator;
|
|
12
|
-
constructor(joinType: JoinType, table: string | TableName | SelectQuery | RawStatement);
|
|
13
|
-
get _type(): SerializationType;
|
|
14
|
-
on(...conditions: Serializable[]): this;
|
|
15
|
-
_serialize(ctx: SerializeContext): string;
|
|
16
|
-
protected __serializeConditions(ctx: any, join: JoinStatement): any;
|
|
17
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { SerializationType } from '../enums.js';
|
|
2
|
-
import { Serializable } from '../serializable.js';
|
|
3
|
-
import { SerializeContext } from '../serialize-context.js';
|
|
4
|
-
export declare class MaxStatement extends Serializable {
|
|
5
|
-
_expression: any;
|
|
6
|
-
_alias?: string;
|
|
7
|
-
constructor(expression: any);
|
|
8
|
-
get _type(): SerializationType;
|
|
9
|
-
/**
|
|
10
|
-
* Sets alias to case expression.
|
|
11
|
-
*/
|
|
12
|
-
as(alias: string): this;
|
|
13
|
-
/**
|
|
14
|
-
* Performs serialization
|
|
15
|
-
*
|
|
16
|
-
* @param {Object} ctx
|
|
17
|
-
* @return {string}
|
|
18
|
-
* @override
|
|
19
|
-
*/
|
|
20
|
-
_serialize(ctx: SerializeContext): string;
|
|
21
|
-
protected __defaultSerialize(ctx: SerializeContext, o: any): string;
|
|
22
|
-
}
|
package/sql-objects/operator.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { 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 abstract class CompOperator extends Operator {
|
|
6
|
-
_left: Serializable | string;
|
|
7
|
-
_right?: any | Serializable;
|
|
8
|
-
_symbol?: string;
|
|
9
|
-
_isArray?: boolean;
|
|
10
|
-
protected constructor(left: string | Serializable, right?: any);
|
|
11
|
-
get _type(): SerializationType;
|
|
12
|
-
_serialize(ctx: SerializeContext): string;
|
|
13
|
-
protected __serializeItem(ctx: SerializeContext, x: string | Serializable, left?: any): any;
|
|
14
|
-
protected __serialize(ctx: SerializeContext, o: any): string;
|
|
15
|
-
protected __defaultSerialize(ctx: SerializeContext, o: any): string;
|
|
16
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { 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 const WrapOps: {};
|
|
6
|
-
export declare abstract class LogicalOperator extends Operator {
|
|
7
|
-
_items: Serializable[];
|
|
8
|
-
constructor(...expressions: any[]);
|
|
9
|
-
get _type(): SerializationType;
|
|
10
|
-
/**
|
|
11
|
-
* Adds operator(s) to item list
|
|
12
|
-
*/
|
|
13
|
-
add(...expressions: (LogicalOperator | any)[]): this;
|
|
14
|
-
_serialize(ctx: SerializeContext): string;
|
|
15
|
-
private _wrapObject;
|
|
16
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import isPlainObject from 'putil-isplainobject';
|
|
2
|
-
import { SerializationType } from '../../enums.js';
|
|
3
|
-
import { printArray } from '../../helpers.js';
|
|
4
|
-
import { isCompOperator, isLogicalOperator, isNotOperator, isRawStatement, } from '../../typeguards.js';
|
|
5
|
-
import { Operator } from '../operator.js';
|
|
6
|
-
export const WrapOps = {};
|
|
7
|
-
// noinspection RegExpUnnecessaryNonCapturingGroup
|
|
8
|
-
const COMPARE_LEFT_PATTERN = /^([\w\\.$]+(?:\[])?) *(.*)$/;
|
|
9
|
-
export class LogicalOperator extends Operator {
|
|
10
|
-
_items = [];
|
|
11
|
-
constructor(...expressions) {
|
|
12
|
-
super();
|
|
13
|
-
this.add(...expressions);
|
|
14
|
-
}
|
|
15
|
-
get _type() {
|
|
16
|
-
return SerializationType.LOGICAL_EXPRESSION;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Adds operator(s) to item list
|
|
20
|
-
*/
|
|
21
|
-
add(...expressions) {
|
|
22
|
-
for (const item of expressions) {
|
|
23
|
-
if (!item)
|
|
24
|
-
continue;
|
|
25
|
-
if (isLogicalOperator(item)) {
|
|
26
|
-
this._items.push(item);
|
|
27
|
-
}
|
|
28
|
-
else if (isRawStatement(item) ||
|
|
29
|
-
isCompOperator(item) ||
|
|
30
|
-
isNotOperator(item)) {
|
|
31
|
-
this._items.push(item);
|
|
32
|
-
}
|
|
33
|
-
else if (isPlainObject(item)) {
|
|
34
|
-
this.add(...this._wrapObject(item));
|
|
35
|
-
}
|
|
36
|
-
else
|
|
37
|
-
throw new TypeError('Operator or Raw type required');
|
|
38
|
-
}
|
|
39
|
-
return this;
|
|
40
|
-
}
|
|
41
|
-
_serialize(ctx) {
|
|
42
|
-
const arr = [];
|
|
43
|
-
for (const t of this._items) {
|
|
44
|
-
const s = ctx.anyToSQL(t);
|
|
45
|
-
/* istanbul ignore else */
|
|
46
|
-
if (s)
|
|
47
|
-
arr.push(s);
|
|
48
|
-
}
|
|
49
|
-
return ctx.serialize(SerializationType.LOGICAL_EXPRESSION, arr, () => {
|
|
50
|
-
const s = printArray(arr, ' ' + String(this._operatorType));
|
|
51
|
-
return s.indexOf('\n') > 0 ? s.replace('\n', '\n\t') + '\b' : s;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
// noinspection JSMethodCanBeStatic
|
|
55
|
-
_wrapObject(obj) {
|
|
56
|
-
const result = [];
|
|
57
|
-
for (const n of Object.getOwnPropertyNames(obj)) {
|
|
58
|
-
let op;
|
|
59
|
-
const v = obj[n];
|
|
60
|
-
if (['and', 'or'].includes(n.toLowerCase())) {
|
|
61
|
-
op = WrapOps[n.toLowerCase()];
|
|
62
|
-
if (!op)
|
|
63
|
-
throw new Error(`Unknown operator "${n}"`);
|
|
64
|
-
result.push(Array.isArray(v) ? op(...v) : op(v));
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if (['exists', '!exists'].includes(n))
|
|
68
|
-
result.push(WrapOps[n](obj[n]));
|
|
69
|
-
else {
|
|
70
|
-
const m = n.match(COMPARE_LEFT_PATTERN);
|
|
71
|
-
if (!m)
|
|
72
|
-
throw new TypeError(`"${n}" is not a valid expression definition`);
|
|
73
|
-
op = WrapOps[m[2] || 'eq'];
|
|
74
|
-
if (!op)
|
|
75
|
-
throw new Error(`Unknown operator "${m[2]}"`);
|
|
76
|
-
result.push(op(m[1], obj[n]));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
export declare class OpBetween extends CompOperator {
|
|
6
|
-
_operatorType: OperatorType;
|
|
7
|
-
_symbol: string;
|
|
8
|
-
constructor(left: string | Serializable, right: any[]);
|
|
9
|
-
_serialize(ctx: SerializeContext): string;
|
|
10
|
-
__defaultSerialize(ctx: any, o: any): string;
|
|
11
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums.js';
|
|
2
|
-
import { Serializable } from '../../serializable.js';
|
|
3
|
-
import { CompOperator } from './comp-operator.js';
|
|
4
|
-
export declare class OpEq extends CompOperator {
|
|
5
|
-
_operatorType: OperatorType;
|
|
6
|
-
_symbol: string;
|
|
7
|
-
constructor(left: string | Serializable, right: any);
|
|
8
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
export declare class OpExists extends CompOperator {
|
|
6
|
-
_operatorType: OperatorType;
|
|
7
|
-
_symbol: string;
|
|
8
|
-
constructor(query: SelectQuery);
|
|
9
|
-
_serialize(ctx: SerializeContext): string;
|
|
10
|
-
protected __defaultSerialize(ctx: SerializeContext, o: any): string;
|
|
11
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
}
|
|
13
|
-
_serialize(ctx) {
|
|
14
|
-
const left = this.__serializeItem(ctx, this._left);
|
|
15
|
-
if (this._isArray)
|
|
16
|
-
left.isArray = true;
|
|
17
|
-
const o = {
|
|
18
|
-
operatorType: this._operatorType,
|
|
19
|
-
symbol: this._symbol,
|
|
20
|
-
left,
|
|
21
|
-
};
|
|
22
|
-
return this.__serialize(ctx, o);
|
|
23
|
-
}
|
|
24
|
-
__defaultSerialize(ctx, o) {
|
|
25
|
-
return o.left.expression ? o.symbol + ' ' + o.left.expression : '';
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums.js';
|
|
2
|
-
import { Serializable } from '../../serializable.js';
|
|
3
|
-
import { CompOperator } from './comp-operator.js';
|
|
4
|
-
export declare class OpGt extends CompOperator {
|
|
5
|
-
_operatorType: OperatorType;
|
|
6
|
-
_symbol: string;
|
|
7
|
-
constructor(left: string | Serializable, right?: any);
|
|
8
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums.js';
|
|
2
|
-
import { Serializable } from '../../serializable.js';
|
|
3
|
-
import { CompOperator } from './comp-operator.js';
|
|
4
|
-
export declare class OpGte extends CompOperator {
|
|
5
|
-
_operatorType: OperatorType;
|
|
6
|
-
_symbol: string;
|
|
7
|
-
constructor(left: string | Serializable, right?: any);
|
|
8
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums.js';
|
|
2
|
-
import { SerializeContext } from '../../serialize-context.js';
|
|
3
|
-
import { CompOperator } from './comp-operator.js';
|
|
4
|
-
export declare class OpIn extends CompOperator {
|
|
5
|
-
_operatorType: OperatorType;
|
|
6
|
-
_symbol: string;
|
|
7
|
-
constructor(left: any, right: any);
|
|
8
|
-
_serialize(ctx: SerializeContext): string;
|
|
9
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums.js';
|
|
2
|
-
import { Serializable } from '../../serializable.js';
|
|
3
|
-
import { CompOperator } from './comp-operator.js';
|
|
4
|
-
export declare class OpIsNot extends CompOperator {
|
|
5
|
-
_operatorType: OperatorType;
|
|
6
|
-
_symbol: string;
|
|
7
|
-
constructor(left: string | Serializable, right?: any);
|
|
8
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
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,8 +0,0 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums.js';
|
|
2
|
-
import { Serializable } from '../../serializable.js';
|
|
3
|
-
import { CompOperator } from './comp-operator.js';
|
|
4
|
-
export declare class OpIs extends CompOperator {
|
|
5
|
-
_operatorType: OperatorType;
|
|
6
|
-
_symbol: string;
|
|
7
|
-
constructor(left: string | Serializable, right?: any);
|
|
8
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
export declare class OpLike extends CompOperator {
|
|
6
|
-
_operatorType: OperatorType;
|
|
7
|
-
_symbol: string;
|
|
8
|
-
constructor(left: string | Serializable, right?: any);
|
|
9
|
-
protected __serialize(ctx: SerializeContext, o: any): string;
|
|
10
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums.js';
|
|
2
|
-
import { CompOperator } from './comp-operator.js';
|
|
3
|
-
export class OpLike extends CompOperator {
|
|
4
|
-
_operatorType = OperatorType.like;
|
|
5
|
-
_symbol = 'like';
|
|
6
|
-
constructor(left, right) {
|
|
7
|
-
super(left, right);
|
|
8
|
-
}
|
|
9
|
-
__serialize(ctx, o) {
|
|
10
|
-
if (!o.right.expression)
|
|
11
|
-
return '';
|
|
12
|
-
if (o.right && typeof o.right.expression !== 'string')
|
|
13
|
-
o.right.expression = String(o.right.expression);
|
|
14
|
-
return ctx.serialize(this._type, o, (_ctx, _o) => this.__defaultSerialize(_ctx, _o));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums.js';
|
|
2
|
-
import { Serializable } from '../../serializable.js';
|
|
3
|
-
import { CompOperator } from './comp-operator.js';
|
|
4
|
-
export declare class OpLt extends CompOperator {
|
|
5
|
-
_operatorType: OperatorType;
|
|
6
|
-
_symbol: string;
|
|
7
|
-
constructor(left: string | Serializable, right?: any);
|
|
8
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums.js';
|
|
2
|
-
import { Serializable } from '../../serializable.js';
|
|
3
|
-
import { CompOperator } from './comp-operator.js';
|
|
4
|
-
export declare class OpLte extends CompOperator {
|
|
5
|
-
_operatorType: OperatorType;
|
|
6
|
-
_symbol: string;
|
|
7
|
-
constructor(left: string | Serializable, right?: any);
|
|
8
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { OperatorType } from '../../enums.js';
|
|
2
|
-
import { Serializable } from '../../serializable.js';
|
|
3
|
-
import { CompOperator } from './comp-operator.js';
|
|
4
|
-
export declare class OpNe extends CompOperator {
|
|
5
|
-
_operatorType: OperatorType;
|
|
6
|
-
_symbol: string;
|
|
7
|
-
constructor(left: string | Serializable, right?: any);
|
|
8
|
-
}
|