@sqb/builder 4.26.0 → 5.0.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.
Files changed (210) hide show
  1. package/index.d.ts +4 -14
  2. package/index.js +4 -14
  3. package/op.ns.d.ts +64 -0
  4. package/op.ns.js +65 -0
  5. package/package.json +2 -1
  6. package/serializable.d.ts +10 -3
  7. package/serializable.js +7 -2
  8. package/serialize-context.d.ts +2 -2
  9. package/serialize-context.js +1 -1
  10. package/{query/delete-query.d.ts → sql/delete.d.ts} +14 -6
  11. package/{query/delete-query.js → sql/delete.js} +24 -20
  12. package/sql/elements/base-field.d.ts +18 -0
  13. package/sql/elements/base-field.js +12 -0
  14. package/{sql-objects/case-statement.d.ts → sql/elements/case.d.ts} +17 -9
  15. package/{sql-objects/case-statement.js → sql/elements/case.js} +13 -9
  16. package/sql/elements/coalesce.d.ts +30 -0
  17. package/{sql-objects/coalesce-statement.js → sql/elements/coalesce.js} +11 -7
  18. package/sql/elements/count.d.ts +29 -0
  19. package/{sql-objects/count-statement.js → sql/elements/count.js} +10 -3
  20. package/sql/elements/field.d.ts +27 -0
  21. package/sql/elements/field.js +54 -0
  22. package/sql/elements/group-column.d.ts +16 -0
  23. package/{sql-objects → sql/elements}/group-column.js +19 -15
  24. package/sql/elements/index.d.ts +26 -0
  25. package/sql/elements/index.js +26 -0
  26. package/sql/elements/join-cross.d.ts +15 -0
  27. package/sql/elements/join-cross.js +11 -0
  28. package/sql/elements/join-full-outer.d.ts +15 -0
  29. package/sql/elements/join-full-outer.js +11 -0
  30. package/sql/elements/join-inner.d.ts +15 -0
  31. package/sql/elements/join-inner.js +11 -0
  32. package/sql/elements/join-left-outer.d.ts +15 -0
  33. package/sql/elements/join-left-outer.js +11 -0
  34. package/sql/elements/join-left.d.ts +15 -0
  35. package/sql/elements/join-left.js +11 -0
  36. package/sql/elements/join-outer.d.ts +15 -0
  37. package/sql/elements/join-outer.js +11 -0
  38. package/sql/elements/join-right-outer.d.ts +15 -0
  39. package/sql/elements/join-right-outer.js +11 -0
  40. package/sql/elements/join-right.d.ts +15 -0
  41. package/sql/elements/join-right.js +11 -0
  42. package/sql/elements/join.d.ts +25 -0
  43. package/{sql-objects/join-statement.js → sql/elements/join.js} +24 -19
  44. package/sql/elements/lower.d.ts +30 -0
  45. package/{sql-objects/lower-statement.js → sql/elements/lower.js} +11 -7
  46. package/{sql-objects/min-statement.d.ts → sql/elements/max.d.ts} +13 -5
  47. package/{sql-objects/max-statement.js → sql/elements/max.js} +11 -7
  48. package/{sql-objects/lower-statement.d.ts → sql/elements/min.d.ts} +13 -4
  49. package/{sql-objects/min-statement.js → sql/elements/min.js} +10 -3
  50. package/sql/elements/order-column.d.ts +17 -0
  51. package/sql/elements/order-column.js +43 -0
  52. package/sql/elements/param.d.ts +36 -0
  53. package/{sql-objects/param-expression.js → sql/elements/param.js} +26 -13
  54. package/sql/elements/raw.d.ts +17 -0
  55. package/sql/elements/raw.js +19 -0
  56. package/sql/elements/returning-column.d.ts +17 -0
  57. package/sql/elements/returning-column.js +32 -0
  58. package/sql/elements/sequence.d.ts +32 -0
  59. package/{sql-objects/sequence-getter-statement.js → sql/elements/sequence.js} +12 -8
  60. package/{sql-objects/string-agg-statement.d.ts → sql/elements/string-agg.d.ts} +13 -5
  61. package/{sql-objects/string-agg-statement.js → sql/elements/string-agg.js} +15 -12
  62. package/sql/elements/table-name.d.ts +32 -0
  63. package/sql/elements/table-name.js +59 -0
  64. package/sql/elements/upper.d.ts +30 -0
  65. package/{sql-objects/upper-statement.js → sql/elements/upper.js} +11 -7
  66. package/sql/index.d.ts +9 -0
  67. package/sql/index.js +9 -0
  68. package/sql/insert.d.ts +37 -0
  69. package/{query/insert-query.js → sql/insert.js} +33 -18
  70. package/sql/operators/and.d.ts +14 -0
  71. package/sql/operators/and.js +13 -0
  72. package/sql/operators/between.d.ts +18 -0
  73. package/{sql-objects/operators/op-between.js → sql/operators/between.js} +20 -8
  74. package/sql/operators/comp-operator.d.ts +24 -0
  75. package/{sql-objects → sql}/operators/comp-operator.js +27 -21
  76. package/sql/operators/eq.d.ts +13 -0
  77. package/sql/operators/eq.js +23 -0
  78. package/sql/operators/exists.d.ts +17 -0
  79. package/sql/operators/exists.js +31 -0
  80. package/sql/operators/gt.d.ts +13 -0
  81. package/sql/operators/gt.js +20 -0
  82. package/sql/operators/gte.d.ts +13 -0
  83. package/sql/operators/gte.js +20 -0
  84. package/sql/operators/i-like.d.ts +13 -0
  85. package/sql/operators/i-like.js +21 -0
  86. package/sql/operators/in.d.ts +15 -0
  87. package/sql/operators/in.js +27 -0
  88. package/sql/operators/index.d.ts +24 -0
  89. package/sql/operators/index.js +24 -0
  90. package/sql/operators/is-not.d.ts +13 -0
  91. package/sql/operators/is-not.js +13 -0
  92. package/sql/operators/is.d.ts +13 -0
  93. package/sql/operators/is.js +20 -0
  94. package/sql/operators/like.d.ts +15 -0
  95. package/sql/operators/like.js +27 -0
  96. package/sql/operators/logical-operator.d.ts +15 -0
  97. package/sql/operators/logical-operator.js +86 -0
  98. package/sql/operators/lt.d.ts +13 -0
  99. package/sql/operators/lt.js +20 -0
  100. package/sql/operators/lte.d.ts +13 -0
  101. package/sql/operators/lte.js +20 -0
  102. package/sql/operators/ne.d.ts +13 -0
  103. package/sql/operators/ne.js +20 -0
  104. package/sql/operators/not-between.d.ts +15 -0
  105. package/sql/operators/not-between.js +13 -0
  106. package/sql/operators/not-exists.d.ts +14 -0
  107. package/sql/operators/not-exists.js +13 -0
  108. package/sql/operators/not-i-like.d.ts +13 -0
  109. package/sql/operators/not-i-like.js +13 -0
  110. package/sql/operators/not-in.d.ts +13 -0
  111. package/sql/operators/not-in.js +13 -0
  112. package/sql/operators/not-like.d.ts +13 -0
  113. package/sql/operators/not-like.js +13 -0
  114. package/sql/operators/not.d.ts +18 -0
  115. package/sql/operators/not.js +20 -0
  116. package/sql/operators/operator.d.ts +12 -0
  117. package/sql/operators/operator.js +11 -0
  118. package/sql/operators/or.d.ts +12 -0
  119. package/sql/operators/or.js +12 -0
  120. package/sql/query.d.ts +31 -0
  121. package/{query → sql}/query.js +13 -7
  122. package/sql/returning-query.d.ts +23 -0
  123. package/{query → sql}/returning-query.js +13 -3
  124. package/{query/select-query.d.ts → sql/select.d.ts} +20 -12
  125. package/{query/select-query.js → sql/select.js} +37 -18
  126. package/{query/union-query.d.ts → sql/union.d.ts} +10 -2
  127. package/{query/union-query.js → sql/union.js} +10 -6
  128. package/sql/update.d.ts +38 -0
  129. package/{query/update-query.js → sql/update.js} +34 -25
  130. package/type-guards.d.ts +21 -0
  131. package/{typeguards.js → type-guards.js} +10 -10
  132. package/classes.ns.d.ts +0 -38
  133. package/classes.ns.js +0 -38
  134. package/op.initializers.d.ts +0 -89
  135. package/op.initializers.js +0 -131
  136. package/query/insert-query.d.ts +0 -23
  137. package/query/query.d.ts +0 -25
  138. package/query/returning-query.d.ts +0 -14
  139. package/query/update-query.d.ts +0 -29
  140. package/sql-objects/base-field.d.ts +0 -7
  141. package/sql-objects/base-field.js +0 -7
  142. package/sql-objects/coalesce-statement.d.ts +0 -22
  143. package/sql-objects/count-statement.d.ts +0 -20
  144. package/sql-objects/expression.d.ts +0 -7
  145. package/sql-objects/expression.js +0 -6
  146. package/sql-objects/field-expression.d.ts +0 -14
  147. package/sql-objects/field-expression.js +0 -50
  148. package/sql-objects/group-column.d.ts +0 -8
  149. package/sql-objects/join-statement.d.ts +0 -17
  150. package/sql-objects/max-statement.d.ts +0 -22
  151. package/sql-objects/operator.d.ts +0 -5
  152. package/sql-objects/operator.js +0 -3
  153. package/sql-objects/operators/comp-operator.d.ts +0 -16
  154. package/sql-objects/operators/logical-operator.d.ts +0 -16
  155. package/sql-objects/operators/logical-operator.js +0 -81
  156. package/sql-objects/operators/op-and.d.ts +0 -5
  157. package/sql-objects/operators/op-and.js +0 -5
  158. package/sql-objects/operators/op-between.d.ts +0 -11
  159. package/sql-objects/operators/op-eq.d.ts +0 -8
  160. package/sql-objects/operators/op-eq.js +0 -9
  161. package/sql-objects/operators/op-exists.d.ts +0 -11
  162. package/sql-objects/operators/op-exists.js +0 -27
  163. package/sql-objects/operators/op-gt.d.ts +0 -8
  164. package/sql-objects/operators/op-gt.js +0 -9
  165. package/sql-objects/operators/op-gte.d.ts +0 -8
  166. package/sql-objects/operators/op-gte.js +0 -9
  167. package/sql-objects/operators/op-ilike.d.ts +0 -6
  168. package/sql-objects/operators/op-ilike.js +0 -6
  169. package/sql-objects/operators/op-in.d.ts +0 -9
  170. package/sql-objects/operators/op-in.js +0 -15
  171. package/sql-objects/operators/op-is-not.d.ts +0 -8
  172. package/sql-objects/operators/op-is-not.js +0 -9
  173. package/sql-objects/operators/op-is.d.ts +0 -8
  174. package/sql-objects/operators/op-is.js +0 -9
  175. package/sql-objects/operators/op-like.d.ts +0 -10
  176. package/sql-objects/operators/op-like.js +0 -16
  177. package/sql-objects/operators/op-lt.d.ts +0 -8
  178. package/sql-objects/operators/op-lt.js +0 -9
  179. package/sql-objects/operators/op-lte.d.ts +0 -8
  180. package/sql-objects/operators/op-lte.js +0 -9
  181. package/sql-objects/operators/op-ne.d.ts +0 -8
  182. package/sql-objects/operators/op-ne.js +0 -9
  183. package/sql-objects/operators/op-not-between.d.ts +0 -6
  184. package/sql-objects/operators/op-not-between.js +0 -6
  185. package/sql-objects/operators/op-not-exists.d.ts +0 -6
  186. package/sql-objects/operators/op-not-exists.js +0 -6
  187. package/sql-objects/operators/op-not-ilike.d.ts +0 -6
  188. package/sql-objects/operators/op-not-ilike.js +0 -6
  189. package/sql-objects/operators/op-not-in.d.ts +0 -6
  190. package/sql-objects/operators/op-not-in.js +0 -6
  191. package/sql-objects/operators/op-not-like.d.ts +0 -6
  192. package/sql-objects/operators/op-not-like.js +0 -6
  193. package/sql-objects/operators/op-not.d.ts +0 -11
  194. package/sql-objects/operators/op-not.js +0 -17
  195. package/sql-objects/operators/op-or.d.ts +0 -5
  196. package/sql-objects/operators/op-or.js +0 -5
  197. package/sql-objects/order-column.d.ts +0 -9
  198. package/sql-objects/order-column.js +0 -39
  199. package/sql-objects/param-expression.d.ts +0 -23
  200. package/sql-objects/raw-statement.d.ts +0 -9
  201. package/sql-objects/raw-statement.js +0 -15
  202. package/sql-objects/returning-column.d.ts +0 -9
  203. package/sql-objects/returning-column.js +0 -27
  204. package/sql-objects/sequence-getter-statement.d.ts +0 -24
  205. package/sql-objects/table-name.d.ts +0 -22
  206. package/sql-objects/table-name.js +0 -55
  207. package/sql-objects/upper-statement.d.ts +0 -22
  208. package/sqlobject.initializers.d.ts +0 -61
  209. package/sqlobject.initializers.js +0 -115
  210. package/typeguards.d.ts +0 -37
@@ -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,7 +0,0 @@
1
- import { DataType } from '../enums.js';
2
- import { Serializable } from '../serializable.js';
3
- export declare abstract class Expression extends Serializable {
4
- _dataType?: DataType;
5
- _isArray?: boolean;
6
- _isDataSet?: boolean;
7
- }
@@ -1,6 +0,0 @@
1
- import { Serializable } from '../serializable.js';
2
- export class Expression extends Serializable {
3
- _dataType;
4
- _isArray;
5
- _isDataSet;
6
- }
@@ -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
- }
@@ -1,5 +0,0 @@
1
- import { OperatorType } from '../enums.js';
2
- import { Serializable } from '../serializable.js';
3
- export declare abstract class Operator extends Serializable {
4
- abstract _operatorType: OperatorType;
5
- }
@@ -1,3 +0,0 @@
1
- import { Serializable } from '../serializable.js';
2
- export class Operator extends Serializable {
3
- }
@@ -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,5 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { LogicalOperator } from './logical-operator.js';
3
- export declare class OpAnd extends LogicalOperator {
4
- _operatorType: OperatorType;
5
- }
@@ -1,5 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { LogicalOperator } from './logical-operator.js';
3
- export class OpAnd extends LogicalOperator {
4
- _operatorType = OperatorType.and;
5
- }
@@ -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,9 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { CompOperator } from './comp-operator.js';
3
- export class OpEq extends CompOperator {
4
- _operatorType = OperatorType.eq;
5
- _symbol = '=';
6
- constructor(left, right) {
7
- super(left, right);
8
- }
9
- }
@@ -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,9 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { CompOperator } from './comp-operator.js';
3
- export class OpGt extends CompOperator {
4
- _operatorType = OperatorType.gt;
5
- _symbol = '>';
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 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 { CompOperator } from './comp-operator.js';
3
- export class OpGte extends CompOperator {
4
- _operatorType = OperatorType.gte;
5
- _symbol = '>=';
6
- constructor(left, right) {
7
- super(left, right);
8
- }
9
- }
@@ -1,6 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { OpLike } from './op-like.js';
3
- export declare class OpILike extends OpLike {
4
- _operatorType: OperatorType;
5
- _symbol: string;
6
- }
@@ -1,6 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { OpLike } from './op-like.js';
3
- export class OpILike extends OpLike {
4
- _operatorType = OperatorType.iLike;
5
- _symbol = 'ilike';
6
- }
@@ -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,9 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { CompOperator } from './comp-operator.js';
3
- export class OpIs extends CompOperator {
4
- _operatorType = OperatorType.is;
5
- _symbol = 'is';
6
- constructor(left, right) {
7
- super(left, right);
8
- }
9
- }
@@ -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,9 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { CompOperator } from './comp-operator.js';
3
- export class OpLt extends CompOperator {
4
- _operatorType = OperatorType.lt;
5
- _symbol = '<';
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 OpLte 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 OpLte extends CompOperator {
4
- _operatorType = OperatorType.lte;
5
- _symbol = '<=';
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 OpNe 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 OpNe extends CompOperator {
4
- _operatorType = OperatorType.ne;
5
- _symbol = '!=';
6
- constructor(left, right) {
7
- super(left, right);
8
- }
9
- }
@@ -1,6 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { OpBetween } from './op-between.js';
3
- export declare class OpNotBetween extends OpBetween {
4
- _operatorType: OperatorType;
5
- _symbol: string;
6
- }
@@ -1,6 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { OpBetween } from './op-between.js';
3
- export class OpNotBetween extends OpBetween {
4
- _operatorType = OperatorType.notBetween;
5
- _symbol = 'not between';
6
- }
@@ -1,6 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { OpExists } from './op-exists.js';
3
- export declare class OpNotExists extends OpExists {
4
- _operatorType: OperatorType;
5
- _symbol: string;
6
- }
@@ -1,6 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { OpExists } from './op-exists.js';
3
- export class OpNotExists extends OpExists {
4
- _operatorType = OperatorType.notExists;
5
- _symbol = 'not exists';
6
- }
@@ -1,6 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { OpILike } from './op-ilike.js';
3
- export declare class OpNotILike extends OpILike {
4
- _operatorType: OperatorType;
5
- _symbol: string;
6
- }
@@ -1,6 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { OpILike } from './op-ilike.js';
3
- export class OpNotILike extends OpILike {
4
- _operatorType = OperatorType.notILike;
5
- _symbol = 'not ilike';
6
- }
@@ -1,6 +0,0 @@
1
- import { OperatorType } from '../../enums.js';
2
- import { OpIn } from './op-in.js';
3
- export declare class OpNotIn extends OpIn {
4
- _operatorType: OperatorType;
5
- _symbol: string;
6
- }