@sqb/builder 5.0.0 → 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.
Files changed (63) hide show
  1. package/package.json +1 -1
  2. package/serializable.d.ts +8 -6
  3. package/serializable.js +6 -4
  4. package/serialize-context.js +2 -2
  5. package/sql/elements/base-field.d.ts +2 -2
  6. package/sql/elements/base-field.js +3 -3
  7. package/sql/elements/case.d.ts +3 -3
  8. package/sql/elements/case.js +3 -3
  9. package/sql/elements/coalesce.d.ts +2 -2
  10. package/sql/elements/coalesce.js +3 -3
  11. package/sql/elements/count.d.ts +2 -2
  12. package/sql/elements/count.js +3 -3
  13. package/sql/elements/join.d.ts +3 -3
  14. package/sql/elements/join.js +3 -3
  15. package/sql/elements/lower.d.ts +2 -2
  16. package/sql/elements/lower.js +3 -3
  17. package/sql/elements/max.d.ts +2 -2
  18. package/sql/elements/max.js +3 -3
  19. package/sql/elements/min.d.ts +2 -2
  20. package/sql/elements/min.js +2 -2
  21. package/sql/elements/order-column.js +2 -2
  22. package/sql/elements/param.d.ts +2 -2
  23. package/sql/elements/param.js +3 -3
  24. package/sql/elements/raw.d.ts +2 -2
  25. package/sql/elements/raw.js +3 -3
  26. package/sql/elements/returning-column.js +2 -2
  27. package/sql/elements/sequence.d.ts +2 -2
  28. package/sql/elements/sequence.js +3 -3
  29. package/sql/elements/string-agg.d.ts +7 -7
  30. package/sql/elements/string-agg.js +3 -3
  31. package/sql/elements/table-name.d.ts +2 -2
  32. package/sql/elements/table-name.js +3 -3
  33. package/sql/elements/upper.d.ts +2 -2
  34. package/sql/elements/upper.js +3 -3
  35. package/sql/insert.js +2 -2
  36. package/sql/operators/between.d.ts +5 -5
  37. package/sql/operators/comp-operator.d.ts +6 -6
  38. package/sql/operators/comp-operator.js +3 -3
  39. package/sql/operators/eq.d.ts +3 -3
  40. package/sql/operators/gt.d.ts +3 -3
  41. package/sql/operators/gte.d.ts +3 -3
  42. package/sql/operators/i-like.d.ts +3 -3
  43. package/sql/operators/in.d.ts +3 -3
  44. package/sql/operators/is-not.d.ts +3 -3
  45. package/sql/operators/is.d.ts +3 -3
  46. package/sql/operators/like.d.ts +3 -3
  47. package/sql/operators/logical-operator.d.ts +2 -2
  48. package/sql/operators/lt.d.ts +3 -3
  49. package/sql/operators/lte.d.ts +3 -3
  50. package/sql/operators/ne.d.ts +3 -3
  51. package/sql/operators/not-between.d.ts +5 -5
  52. package/sql/operators/not-i-like.d.ts +3 -3
  53. package/sql/operators/not-in.d.ts +3 -3
  54. package/sql/operators/not-like.d.ts +3 -3
  55. package/sql/operators/not.d.ts +4 -4
  56. package/sql/operators/operator.d.ts +2 -2
  57. package/sql/operators/operator.js +3 -3
  58. package/sql/query.d.ts +2 -2
  59. package/sql/query.js +3 -3
  60. package/sql/select.d.ts +11 -11
  61. package/sql/update.js +2 -2
  62. package/type-guards.d.ts +3 -2
  63. package/type-guards.js +5 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqb/builder",
3
3
  "description": "Extensible multi-dialect SQL query builder written with TypeScript",
4
- "version": "5.0.0",
4
+ "version": "5.0.1",
5
5
  "author": "Panates",
6
6
  "license": "Apache-2.0",
7
7
  "dependencies": {
package/serializable.d.ts CHANGED
@@ -1,16 +1,18 @@
1
1
  import type { SerializationType } from './enums.js';
2
2
  import type { SerializeContext } from './serialize-context.js';
3
- export interface Serializable {
3
+ export interface SqlElement {
4
4
  _type: SerializationType;
5
5
  /**
6
6
  * Performs serialization
7
7
  */
8
8
  _serialize(ctx: SerializeContext): string;
9
9
  }
10
- interface SerializableCtor {
11
- new (): Serializable;
12
- (): Serializable;
13
- prototype: Serializable;
10
+ interface SqlElementCtor {
11
+ new (): SqlElement;
12
+ (): SqlElement;
13
+ prototype: SqlElement;
14
14
  }
15
- export declare const Serializable: SerializableCtor;
15
+ export declare const SqlElement: SqlElementCtor;
16
+ export declare const Serializable: SqlElementCtor;
17
+ export type Serializable = SqlElement;
16
18
  export {};
package/serializable.js CHANGED
@@ -1,7 +1,9 @@
1
- export const Serializable = function () {
1
+ export const SqlElement = function () {
2
2
  if (!this)
3
- return new Serializable();
4
- if (this.constructor === Serializable) {
5
- throw new TypeError('Serializable is abstract and cannot be instantiated');
3
+ return new SqlElement();
4
+ if (this.constructor === SqlElement) {
5
+ throw new TypeError('SqlElement is abstract and cannot be instantiated');
6
6
  }
7
7
  };
8
+ /* Backward compatibility */
9
+ export const Serializable = SqlElement;
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from './enums.js';
2
2
  import { SerializerRegistry } from './extensions.js';
3
- import { Serializable } from './serializable.js';
3
+ import { SqlElement } from './serializable.js';
4
4
  import { isLogicalOperator, isQuery, isSerializable } from './type-guards.js';
5
5
  export class SerializeContext {
6
6
  rootQuery;
@@ -131,7 +131,7 @@ export class SerializeContext {
131
131
  if (typeof v === 'number') {
132
132
  return this.serialize(SerializationType.NUMBER_VALUE, v, () => this.numberToSQL(v));
133
133
  }
134
- if (v instanceof Serializable)
134
+ if (v instanceof SqlElement)
135
135
  return v._serialize(this);
136
136
  return v;
137
137
  }
@@ -1,6 +1,6 @@
1
1
  import { DataType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
3
- export interface BaseField extends Serializable {
2
+ import { SqlElement } from '../../serializable.js';
3
+ export interface BaseField extends SqlElement {
4
4
  _dataType?: DataType;
5
5
  _isArray?: boolean;
6
6
  _isDataSet?: boolean;
@@ -1,12 +1,12 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  export const BaseField = function () {
3
3
  if (!(this instanceof BaseField))
4
4
  return new BaseField();
5
5
  if (this.constructor === BaseField) {
6
6
  throw new TypeError('BaseField is abstract and cannot be instantiated');
7
7
  }
8
- Serializable.call(this);
8
+ SqlElement.call(this);
9
9
  this._field = '';
10
10
  };
11
- BaseField.prototype = Object.create(Serializable.prototype);
11
+ BaseField.prototype = Object.create(SqlElement.prototype);
12
12
  BaseField.prototype.constructor = BaseField;
@@ -1,12 +1,12 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
4
  import { LogicalOperator } from '../operators/logical-operator.js';
5
5
  import { Operator } from '../operators/operator.js';
6
6
  import { Raw } from './raw.js';
7
- declare class CaseClass extends Serializable {
7
+ declare class CaseClass extends SqlElement {
8
8
  _expressions: {
9
- condition: Serializable;
9
+ condition: SqlElement;
10
10
  value: any;
11
11
  }[];
12
12
  _elseValue: any;
@@ -1,7 +1,7 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { And } from '../operators/and.js';
4
- class CaseClass extends Serializable {
4
+ class CaseClass extends SqlElement {
5
5
  _expressions;
6
6
  _elseValue;
7
7
  _condition;
@@ -84,7 +84,7 @@ class CaseClass extends Serializable {
84
84
  export const Case = function () {
85
85
  if (!(this instanceof Case))
86
86
  return new Case();
87
- Serializable.call(this);
87
+ SqlElement.call(this);
88
88
  this._expressions = [];
89
89
  };
90
90
  Case.prototype = CaseClass.prototype;
@@ -1,7 +1,7 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
- declare class CoalesceClass extends Serializable {
4
+ declare class CoalesceClass extends SqlElement {
5
5
  _expressions: any[];
6
6
  _alias?: string;
7
7
  get _type(): SerializationType;
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
3
- class CoalesceClass extends Serializable {
2
+ import { SqlElement } from '../../serializable.js';
3
+ class CoalesceClass extends SqlElement {
4
4
  _expressions;
5
5
  _alias;
6
6
  get _type() {
@@ -41,7 +41,7 @@ class CoalesceClass extends Serializable {
41
41
  export const Coalesce = function (...expressions) {
42
42
  if (!(this instanceof Coalesce))
43
43
  return new Coalesce(...expressions);
44
- Serializable.call(this);
44
+ SqlElement.call(this);
45
45
  this._expressions = expressions;
46
46
  };
47
47
  Coalesce.prototype = CoalesceClass.prototype;
@@ -1,7 +1,7 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
- declare class CountClass extends Serializable {
4
+ declare class CountClass extends SqlElement {
5
5
  _alias?: string;
6
6
  get _type(): SerializationType;
7
7
  /**
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
3
- class CountClass extends Serializable {
2
+ import { SqlElement } from '../../serializable.js';
3
+ class CountClass extends SqlElement {
4
4
  _alias;
5
5
  get _type() {
6
6
  return SerializationType.COUNT_STATEMENT;
@@ -34,7 +34,7 @@ class CountClass extends Serializable {
34
34
  export const Count = function () {
35
35
  if (!(this instanceof Count))
36
36
  return new Count();
37
- Serializable.call(this);
37
+ SqlElement.call(this);
38
38
  };
39
39
  Count.prototype = CountClass.prototype;
40
40
  Count.prototype.constructor = Count;
@@ -1,16 +1,16 @@
1
1
  import { JoinType, SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import type { SerializeContext } from '../../serialize-context.js';
4
4
  import type { LogicalOperator } from '../operators/logical-operator.js';
5
5
  import type { Select } from '../select.js';
6
6
  import type { Raw } from './raw.js';
7
7
  import { TableName } from './table-name.js';
8
- declare class JoinClass extends Serializable {
8
+ declare class JoinClass extends SqlElement {
9
9
  _joinType: JoinType;
10
10
  _table: TableName | Select | Raw;
11
11
  _conditions: LogicalOperator;
12
12
  get _type(): SerializationType;
13
- on(...conditions: Serializable[]): this;
13
+ on(...conditions: SqlElement[]): this;
14
14
  _serialize(ctx: SerializeContext): string;
15
15
  protected __serializeConditions(ctx: any, join: JoinClass): any;
16
16
  }
@@ -1,9 +1,9 @@
1
1
  import { JoinType, SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { isRaw, isSelect, isTableName } from '../../type-guards.js';
4
4
  import { And } from '../operators/and.js';
5
5
  import { TableName } from './table-name.js';
6
- class JoinClass extends Serializable {
6
+ class JoinClass extends SqlElement {
7
7
  _joinType;
8
8
  _table;
9
9
  _conditions = new And();
@@ -79,7 +79,7 @@ class JoinClass extends Serializable {
79
79
  export const Join = function (joinType, table) {
80
80
  if (!(this instanceof Join))
81
81
  return new Join(joinType, table);
82
- Serializable.call(this);
82
+ SqlElement.call(this);
83
83
  // noinspection SuspiciousTypeOfGuard
84
84
  if (!(isSelect(table) ||
85
85
  isRaw(table) ||
@@ -1,7 +1,7 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
- declare class LowerClass extends Serializable {
4
+ declare class LowerClass extends SqlElement {
5
5
  _expression: any;
6
6
  _alias?: string;
7
7
  get _type(): SerializationType;
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
3
- class LowerClass extends Serializable {
2
+ import { SqlElement } from '../../serializable.js';
3
+ class LowerClass extends SqlElement {
4
4
  _expression;
5
5
  _alias;
6
6
  get _type() {
@@ -33,7 +33,7 @@ class LowerClass extends Serializable {
33
33
  export const Lower = function (expression) {
34
34
  if (!(this instanceof Lower))
35
35
  return new Lower(expression);
36
- Serializable.call(this);
36
+ SqlElement.call(this);
37
37
  this._expression = expression;
38
38
  };
39
39
  Lower.prototype = LowerClass.prototype;
@@ -1,7 +1,7 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
- declare class MaxClass extends Serializable {
4
+ declare class MaxClass extends SqlElement {
5
5
  _expression: any;
6
6
  _alias?: string;
7
7
  get _type(): SerializationType;
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
3
- class MaxClass extends Serializable {
2
+ import { SqlElement } from '../../serializable.js';
3
+ class MaxClass extends SqlElement {
4
4
  _expression;
5
5
  _alias;
6
6
  get _type() {
@@ -33,7 +33,7 @@ class MaxClass extends Serializable {
33
33
  export const Max = function (expression) {
34
34
  if (!(this instanceof Max))
35
35
  return new Max(expression);
36
- Serializable.call(this);
36
+ SqlElement.call(this);
37
37
  this._expression = expression;
38
38
  };
39
39
  Max.prototype = MaxClass.prototype;
@@ -1,7 +1,7 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
- declare class MinClass extends Serializable {
4
+ declare class MinClass extends SqlElement {
5
5
  _expression: any;
6
6
  _alias?: string;
7
7
  constructor(expression: any);
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
3
- class MinClass extends Serializable {
2
+ import { SqlElement } from '../../serializable.js';
3
+ class MinClass extends SqlElement {
4
4
  _expression;
5
5
  _alias;
6
6
  constructor(expression) {
@@ -1,5 +1,5 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { BaseField } from './base-field.js';
4
4
  const ORDER_COLUMN_PATTERN = /^([-+])?((?:[a-zA-Z_][\w$]*\.){0,2})([a-zA-Z_][\w$]*|\*) *(asc|dsc|desc|ascending|descending)?$/i;
5
5
  class OrderColumnClass extends BaseField {
@@ -23,7 +23,7 @@ class OrderColumnClass extends BaseField {
23
23
  export const OrderColumn = function (value) {
24
24
  if (!(this instanceof OrderColumn))
25
25
  return new OrderColumn(value);
26
- Serializable.call(this);
26
+ SqlElement.call(this);
27
27
  const m = value.match(ORDER_COLUMN_PATTERN);
28
28
  if (!m)
29
29
  throw new TypeError(`"${value}" does not match order column format`);
@@ -1,7 +1,7 @@
1
1
  import { DataType, SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
- declare class ParamClass extends Serializable {
4
+ declare class ParamClass extends SqlElement {
5
5
  _name: string;
6
6
  _dataType?: DataType;
7
7
  _isArray?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
3
- class ParamClass extends Serializable {
2
+ import { SqlElement } from '../../serializable.js';
3
+ class ParamClass extends SqlElement {
4
4
  _name;
5
5
  _dataType;
6
6
  _isArray;
@@ -56,7 +56,7 @@ export const Param = function (...varArgs) {
56
56
  }
57
57
  if (!(this instanceof Param))
58
58
  return new Param(args);
59
- Serializable.call(this);
59
+ SqlElement.call(this);
60
60
  this._name = args.name;
61
61
  this._dataType = args.dataType;
62
62
  this._isArray = args.isArray;
@@ -1,7 +1,7 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
- declare class RawClass extends Serializable {
4
+ declare class RawClass extends SqlElement {
5
5
  _text: string;
6
6
  get _type(): SerializationType;
7
7
  _serialize(ctx: SerializeContext): string;
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
3
- class RawClass extends Serializable {
2
+ import { SqlElement } from '../../serializable.js';
3
+ class RawClass extends SqlElement {
4
4
  _text;
5
5
  get _type() {
6
6
  return SerializationType.RAW;
@@ -12,7 +12,7 @@ class RawClass extends Serializable {
12
12
  export const Raw = function (str) {
13
13
  if (!(this instanceof Raw))
14
14
  return new Raw(str);
15
- Serializable.call(this);
15
+ SqlElement.call(this);
16
16
  this._text = str;
17
17
  };
18
18
  Raw.prototype = RawClass.prototype;
@@ -1,5 +1,5 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { BaseField } from './base-field.js';
4
4
  const RETURNING_COLUMN_PATTERN = /^([a-zA-Z_]\w*) *(?:as)? *(\w+)?$/;
5
5
  class ReturningColumnClass extends BaseField {
@@ -21,7 +21,7 @@ class ReturningColumnClass extends BaseField {
21
21
  export const ReturningColumn = function (field) {
22
22
  if (!(this instanceof ReturningColumn))
23
23
  return new ReturningColumn(field);
24
- Serializable.call(this);
24
+ SqlElement.call(this);
25
25
  const m = field.match(RETURNING_COLUMN_PATTERN);
26
26
  if (!m)
27
27
  throw new TypeError(`"${field}" does not match returning column format`);
@@ -1,7 +1,7 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
- declare class SequenceClass extends Serializable {
4
+ declare class SequenceClass extends SqlElement {
5
5
  _expression: string;
6
6
  _next: boolean;
7
7
  _alias?: string;
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
3
- class SequenceClass extends Serializable {
2
+ import { SqlElement } from '../../serializable.js';
3
+ class SequenceClass extends SqlElement {
4
4
  _expression;
5
5
  _next;
6
6
  _alias;
@@ -46,7 +46,7 @@ class SequenceClass extends Serializable {
46
46
  export const Sequence = function (expression, next) {
47
47
  if (!(this instanceof Sequence))
48
48
  return new Sequence(expression, next);
49
- Serializable.call(this);
49
+ SqlElement.call(this);
50
50
  this._expression = expression;
51
51
  this._next = !!next;
52
52
  };
@@ -1,18 +1,18 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
4
  import { OrderColumn } from './order-column.js';
5
- declare class StringAggClass extends Serializable {
6
- _field: Serializable;
5
+ declare class StringAggClass extends SqlElement {
6
+ _field: SqlElement;
7
7
  _delimiter: string;
8
- _orderBy?: (OrderColumn | Serializable)[];
8
+ _orderBy?: (OrderColumn | SqlElement)[];
9
9
  _alias?: string;
10
10
  get _type(): SerializationType;
11
11
  delimiter(value: string): this;
12
12
  /**
13
13
  * Defines "order by" part of StringAGG.
14
14
  */
15
- orderBy(...field: (string | Serializable)[]): this;
15
+ orderBy(...field: (string | SqlElement)[]): this;
16
16
  /**
17
17
  * Sets alias to case expression.
18
18
  */
@@ -29,8 +29,8 @@ declare class StringAggClass extends Serializable {
29
29
  protected __defaultSerialize(ctx: SerializeContext, o: any): string;
30
30
  }
31
31
  interface StringAggCtor {
32
- new (field: string | Serializable, delimiter?: string): StringAgg;
33
- (field: string | Serializable, delimiter?: string): StringAgg;
32
+ new (field: string | SqlElement, delimiter?: string): StringAgg;
33
+ (field: string | SqlElement, delimiter?: string): StringAgg;
34
34
  prototype: StringAgg;
35
35
  }
36
36
  export declare const StringAgg: StringAggCtor;
@@ -1,9 +1,9 @@
1
1
  import { SerializationType } from '../../enums.js';
2
2
  import { printArray } from '../../helpers.js';
3
- import { Serializable } from '../../serializable.js';
3
+ import { SqlElement } from '../../serializable.js';
4
4
  import { Field } from './field.js';
5
5
  import { OrderColumn } from './order-column.js';
6
- class StringAggClass extends Serializable {
6
+ class StringAggClass extends SqlElement {
7
7
  _field;
8
8
  _delimiter;
9
9
  _orderBy;
@@ -79,7 +79,7 @@ class StringAggClass extends Serializable {
79
79
  export const StringAgg = function (field, delimiter) {
80
80
  if (!(this instanceof StringAgg))
81
81
  return new StringAgg(field, delimiter);
82
- Serializable.call(this);
82
+ SqlElement.call(this);
83
83
  this._field = typeof field === 'string' ? new Field(field) : field;
84
84
  this._delimiter = delimiter || ',';
85
85
  };
@@ -1,7 +1,7 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
- declare class TableNameClass extends Serializable {
4
+ declare class TableNameClass extends SqlElement {
5
5
  schema?: string;
6
6
  table?: string;
7
7
  alias?: string;
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
3
- class TableNameClass extends Serializable {
2
+ import { SqlElement } from '../../serializable.js';
3
+ class TableNameClass extends SqlElement {
4
4
  schema;
5
5
  table;
6
6
  alias;
@@ -22,7 +22,7 @@ class TableNameClass extends Serializable {
22
22
  export const TableName = function (tableName) {
23
23
  if (!(this instanceof TableName))
24
24
  return new TableName(tableName);
25
- Serializable.call(this);
25
+ SqlElement.call(this);
26
26
  if (typeof tableName === 'string') {
27
27
  const m = tableName.match(/^(?:([a-zA-Z][\w$]*)\.)? *([a-zA-Z][\w$]*) *(?:as)? *(\w+)?$/);
28
28
  if (!m)
@@ -1,7 +1,7 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
- declare class UpperClass extends Serializable {
4
+ declare class UpperClass extends SqlElement {
5
5
  _expression: any;
6
6
  _alias?: string;
7
7
  get _type(): SerializationType;
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
3
- class UpperClass extends Serializable {
2
+ import { SqlElement } from '../../serializable.js';
3
+ class UpperClass extends SqlElement {
4
4
  _expression;
5
5
  _alias;
6
6
  get _type() {
@@ -33,7 +33,7 @@ class UpperClass extends Serializable {
33
33
  export const Upper = function (expression) {
34
34
  if (!(this instanceof Upper))
35
35
  return new Upper(expression);
36
- Serializable.call(this);
36
+ SqlElement.call(this);
37
37
  this._expression = expression;
38
38
  };
39
39
  Upper.prototype = UpperClass.prototype;
package/sql/insert.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from '../enums.js';
2
2
  import { printArray } from '../helpers.js';
3
- import { Serializable } from '../serializable.js';
3
+ import { SqlElement } from '../serializable.js';
4
4
  import { isRaw, isSelect, isSerializable } from '../type-guards.js';
5
5
  import { TableName } from './elements/table-name.js';
6
6
  import { Query } from './query.js';
@@ -77,7 +77,7 @@ export const Insert = function (tableName, input) {
77
77
  }
78
78
  if (!input ||
79
79
  !((typeof input === 'object' && !Array.isArray(input)) ||
80
- (input instanceof Serializable &&
80
+ (input instanceof SqlElement &&
81
81
  (input._type === SerializationType.SELECT_QUERY ||
82
82
  input._type === SerializationType.RAW)))) {
83
83
  throw new TypeError('Object or Select instance required as second argument (input) for Insert');
@@ -1,4 +1,4 @@
1
- import type { Serializable } from '../../serializable.js';
1
+ import type { SqlElement } from '../../serializable.js';
2
2
  import { SerializeContext } from '../../serialize-context.js';
3
3
  import { CompOperator } from './comp-operator.js';
4
4
  declare class BetweenClass extends CompOperator {
@@ -6,10 +6,10 @@ declare class BetweenClass extends CompOperator {
6
6
  __defaultSerialize(ctx: SerializeContext, o: any): string;
7
7
  }
8
8
  interface BetweenCtor {
9
- new (left: string | Serializable, right: any[] | Serializable): Between;
10
- new (left: string | Serializable, right1: any, right2: any): Between;
11
- (left: string | Serializable, right: any[] | Serializable): Between;
12
- (left: string | Serializable, right1: any, right2: any): Between;
9
+ new (left: string | SqlElement, right: any[] | SqlElement): Between;
10
+ new (left: string | SqlElement, right1: any, right2: any): Between;
11
+ (left: string | SqlElement, right: any[] | SqlElement): Between;
12
+ (left: string | SqlElement, right1: any, right2: any): Between;
13
13
  prototype: Between;
14
14
  }
15
15
  export declare const Between: BetweenCtor;
@@ -1,21 +1,21 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
4
  import { Operator } from './operator.js';
5
5
  declare class CompOperatorClass extends Operator {
6
- _left: Serializable | string;
7
- _right?: any | Serializable;
6
+ _left: SqlElement | string;
7
+ _right?: any | SqlElement;
8
8
  _symbol?: string;
9
9
  _isArray?: boolean;
10
10
  get _type(): SerializationType;
11
11
  _serialize(ctx: SerializeContext): string;
12
- __serializeItem(ctx: SerializeContext, x: string | Serializable, left?: any): any;
12
+ __serializeItem(ctx: SerializeContext, x: string | SqlElement, left?: any): any;
13
13
  __serialize(ctx: SerializeContext, o: any): string;
14
14
  __defaultSerialize(ctx: SerializeContext, o: any): string;
15
15
  }
16
16
  interface CompOperatorCtor {
17
- new (left: string | Serializable, right?: any): CompOperator;
18
- (left: string | Serializable, right?: any): CompOperator;
17
+ new (left: string | SqlElement, right?: any): CompOperator;
18
+ (left: string | SqlElement, right?: any): CompOperator;
19
19
  prototype: CompOperator;
20
20
  }
21
21
  export declare const CompOperator: CompOperatorCtor;
@@ -1,5 +1,5 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { Field, Param } from '../elements/index.js';
4
4
  import { Operator } from './operator.js';
5
5
  const EXPRESSION_PATTERN = /^([\w\\.$]+)(\[])?/;
@@ -26,7 +26,7 @@ class CompOperatorClass extends Operator {
26
26
  }
27
27
  __serializeItem(ctx, x, left) {
28
28
  const isRight = !!left;
29
- if (ctx.strictParams && !(x instanceof Serializable) && isRight) {
29
+ if (ctx.strictParams && !(x instanceof SqlElement) && isRight) {
30
30
  ctx.strictParamGenId = ctx.strictParamGenId || 0;
31
31
  const name = 'P$_' + ++ctx.strictParamGenId;
32
32
  ctx.params = ctx.params || {};
@@ -37,7 +37,7 @@ class CompOperatorClass extends Operator {
37
37
  isArray: left?.isArray || Array.isArray(x),
38
38
  });
39
39
  }
40
- if (x instanceof Serializable) {
40
+ if (x instanceof SqlElement) {
41
41
  const expression = ctx.anyToSQL(x);
42
42
  const result = {
43
43
  expression,
@@ -1,10 +1,10 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { CompOperator } from './comp-operator.js';
3
3
  declare class EqClass extends CompOperator {
4
4
  }
5
5
  interface EqCtor {
6
- new (left: string | Serializable, right: any): Eq;
7
- (left: string | Serializable, right: any): Eq;
6
+ new (left: string | SqlElement, right: any): Eq;
7
+ (left: string | SqlElement, right: any): Eq;
8
8
  prototype: Eq;
9
9
  }
10
10
  export declare const Eq: EqCtor;
@@ -1,10 +1,10 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { CompOperator } from './comp-operator.js';
3
3
  declare class GtClass extends CompOperator {
4
4
  }
5
5
  interface GtCtor {
6
- new (left: string | Serializable, right?: any): Gt;
7
- (left: string | Serializable, right?: any): Gt;
6
+ new (left: string | SqlElement, right?: any): Gt;
7
+ (left: string | SqlElement, right?: any): Gt;
8
8
  prototype: Gt;
9
9
  }
10
10
  export declare const Gt: GtCtor;
@@ -1,10 +1,10 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { CompOperator } from './comp-operator.js';
3
3
  declare class GteClass extends CompOperator {
4
4
  }
5
5
  interface GteCtor {
6
- new (left: string | Serializable, right?: any): Gte;
7
- (left: string | Serializable, right?: any): Gte;
6
+ new (left: string | SqlElement, right?: any): Gte;
7
+ (left: string | SqlElement, right?: any): Gte;
8
8
  prototype: Gte;
9
9
  }
10
10
  export declare const Gte: GteCtor;
@@ -1,10 +1,10 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { Like } from './like.js';
3
3
  declare class ILikeClass extends Like {
4
4
  }
5
5
  interface ILikeCtor {
6
- new (left: string | Serializable, right?: string | Serializable): ILike;
7
- (left: string | Serializable, right?: string | Serializable): ILike;
6
+ new (left: string | SqlElement, right?: string | SqlElement): ILike;
7
+ (left: string | SqlElement, right?: string | SqlElement): ILike;
8
8
  prototype: ILike;
9
9
  }
10
10
  export declare const ILike: ILikeCtor;
@@ -1,12 +1,12 @@
1
- import type { Serializable } from '../../serializable.js';
1
+ import type { SqlElement } from '../../serializable.js';
2
2
  import { SerializeContext } from '../../serialize-context.js';
3
3
  import { CompOperator } from './comp-operator.js';
4
4
  declare class InClass extends CompOperator {
5
5
  _serialize(ctx: SerializeContext): string;
6
6
  }
7
7
  interface InCtor {
8
- new (left: string | Serializable, right: any[] | Serializable): In;
9
- (left: string | Serializable, right: any[] | Serializable): In;
8
+ new (left: string | SqlElement, right: any[] | SqlElement): In;
9
+ (left: string | SqlElement, right: any[] | SqlElement): In;
10
10
  prototype: In;
11
11
  }
12
12
  export declare const In: InCtor;
@@ -1,10 +1,10 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { Is } from './is.js';
3
3
  declare class IsNotClass extends Is {
4
4
  }
5
5
  interface IsNotCtor {
6
- new (left: string | Serializable, right?: any): IsNot;
7
- (left: string | Serializable, right?: any): IsNot;
6
+ new (left: string | SqlElement, right?: any): IsNot;
7
+ (left: string | SqlElement, right?: any): IsNot;
8
8
  prototype: IsNot;
9
9
  }
10
10
  export declare const IsNot: IsNotCtor;
@@ -1,10 +1,10 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { CompOperator } from './comp-operator.js';
3
3
  declare class IsClass extends CompOperator {
4
4
  }
5
5
  interface IsCtor {
6
- new (left: string | Serializable, right?: any): Is;
7
- (left: string | Serializable, right?: any): Is;
6
+ new (left: string | SqlElement, right?: any): Is;
7
+ (left: string | SqlElement, right?: any): Is;
8
8
  prototype: Is;
9
9
  }
10
10
  export declare const Is: IsCtor;
@@ -1,12 +1,12 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { SerializeContext } from '../../serialize-context.js';
3
3
  import { CompOperator } from './comp-operator.js';
4
4
  declare class LikeClass extends CompOperator {
5
5
  __serialize(ctx: SerializeContext, o: any): string;
6
6
  }
7
7
  interface LikeCtor {
8
- new (left: string | Serializable, right?: string | Serializable): Like;
9
- (left: string | Serializable, right?: string | Serializable): Like;
8
+ new (left: string | SqlElement, right?: string | SqlElement): Like;
9
+ (left: string | SqlElement, right?: string | SqlElement): Like;
10
10
  prototype: Like;
11
11
  }
12
12
  export declare const Like: LikeCtor;
@@ -1,8 +1,8 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { SerializeContext } from '../../serialize-context.js';
3
3
  import { Operator } from './operator.js';
4
4
  export interface LogicalOperator extends Operator {
5
- _items: Serializable[];
5
+ _items: SqlElement[];
6
6
  add(...expressions: (LogicalOperator | any)[]): this;
7
7
  _serialize(ctx: SerializeContext): string;
8
8
  }
@@ -1,10 +1,10 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { CompOperator } from './comp-operator.js';
3
3
  declare class LtClass extends CompOperator {
4
4
  }
5
5
  interface LtCtor {
6
- new (left: string | Serializable, right?: any): Lt;
7
- (left: string | Serializable, right?: any): Lt;
6
+ new (left: string | SqlElement, right?: any): Lt;
7
+ (left: string | SqlElement, right?: any): Lt;
8
8
  prototype: Lt;
9
9
  }
10
10
  export declare const Lt: LtCtor;
@@ -1,10 +1,10 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { CompOperator } from './comp-operator.js';
3
3
  declare class LteClass extends CompOperator {
4
4
  }
5
5
  interface LteCtor {
6
- new (left: string | Serializable, right?: any): Lte;
7
- (left: string | Serializable, right?: any): Lte;
6
+ new (left: string | SqlElement, right?: any): Lte;
7
+ (left: string | SqlElement, right?: any): Lte;
8
8
  prototype: Lte;
9
9
  }
10
10
  export declare const Lte: LteCtor;
@@ -1,10 +1,10 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { CompOperator } from './comp-operator.js';
3
3
  declare class NeClass extends CompOperator {
4
4
  }
5
5
  interface NeCtor {
6
- new (left: string | Serializable, right?: any): Ne;
7
- (left: string | Serializable, right?: any): Ne;
6
+ new (left: string | SqlElement, right?: any): Ne;
7
+ (left: string | SqlElement, right?: any): Ne;
8
8
  prototype: Ne;
9
9
  }
10
10
  export declare const Ne: NeCtor;
@@ -1,12 +1,12 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { Between } from './between.js';
3
3
  declare class NotBetweenClass extends Between {
4
4
  }
5
5
  interface NotBetweenCtor {
6
- new (left: string | Serializable, right: any[] | Serializable): NotBetween;
7
- new (left: string | Serializable, right1: any, right2: any): NotBetween;
8
- (left: string | Serializable, right: any[] | Serializable): NotBetween;
9
- (left: string | Serializable, right1: any, right2: any): NotBetween;
6
+ new (left: string | SqlElement, right: any[] | SqlElement): NotBetween;
7
+ new (left: string | SqlElement, right1: any, right2: any): NotBetween;
8
+ (left: string | SqlElement, right: any[] | SqlElement): NotBetween;
9
+ (left: string | SqlElement, right1: any, right2: any): NotBetween;
10
10
  prototype: NotBetween;
11
11
  }
12
12
  export declare const NotBetween: NotBetweenCtor;
@@ -1,10 +1,10 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { ILike } from './i-like.js';
3
3
  declare class NotILikeClass extends ILike {
4
4
  }
5
5
  interface NotILikeCtor {
6
- new (left: string | Serializable, right?: string | Serializable): NotILike;
7
- (left: string | Serializable, right?: string | Serializable): NotILike;
6
+ new (left: string | SqlElement, right?: string | SqlElement): NotILike;
7
+ (left: string | SqlElement, right?: string | SqlElement): NotILike;
8
8
  prototype: NotILike;
9
9
  }
10
10
  export declare const NotILike: NotILikeCtor;
@@ -1,10 +1,10 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { In } from './in.js';
3
3
  declare class NotInClass extends In {
4
4
  }
5
5
  interface NotInCtor {
6
- new (left: string | Serializable, right: any[] | Serializable): NotIn;
7
- (left: string | Serializable, right: any[] | Serializable): NotIn;
6
+ new (left: string | SqlElement, right: any[] | SqlElement): NotIn;
7
+ (left: string | SqlElement, right: any[] | SqlElement): NotIn;
8
8
  prototype: NotIn;
9
9
  }
10
10
  export declare const NotIn: NotInCtor;
@@ -1,10 +1,10 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  import { Like } from './like.js';
3
3
  declare class NotLikeClass extends Like {
4
4
  }
5
5
  interface NotLikeCtor {
6
- new (left: string | Serializable, right?: string | Serializable): NotLike;
7
- (left: string | Serializable, right?: string | Serializable): NotLike;
6
+ new (left: string | SqlElement, right?: string | SqlElement): NotLike;
7
+ (left: string | SqlElement, right?: string | SqlElement): NotLike;
8
8
  prototype: NotLike;
9
9
  }
10
10
  export declare const NotLike: NotLikeCtor;
@@ -1,15 +1,15 @@
1
1
  import { SerializationType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
2
+ import { SqlElement } from '../../serializable.js';
3
3
  import { SerializeContext } from '../../serialize-context.js';
4
4
  import { Operator } from '../operators/operator.js';
5
5
  declare class NotClass extends Operator {
6
- _expression: Serializable;
6
+ _expression: SqlElement;
7
7
  get _type(): SerializationType;
8
8
  _serialize(ctx: SerializeContext): string;
9
9
  }
10
10
  interface NotCtor {
11
- new (expression: Serializable): Not;
12
- (expression: Serializable): Not;
11
+ new (expression: SqlElement): Not;
12
+ (expression: SqlElement): Not;
13
13
  prototype: Not;
14
14
  }
15
15
  export declare const Not: NotCtor;
@@ -1,6 +1,6 @@
1
1
  import { OperatorType } from '../../enums.js';
2
- import { Serializable } from '../../serializable.js';
3
- export interface Operator extends Serializable {
2
+ import { SqlElement } from '../../serializable.js';
3
+ export interface Operator extends SqlElement {
4
4
  _operatorType: OperatorType;
5
5
  }
6
6
  interface OperatorCtor {
@@ -1,11 +1,11 @@
1
- import { Serializable } from '../../serializable.js';
1
+ import { SqlElement } from '../../serializable.js';
2
2
  export const Operator = function () {
3
3
  if (!(this instanceof Operator))
4
4
  return new Operator();
5
5
  if (this.constructor === Operator) {
6
6
  throw new TypeError('Operator is abstract and cannot be instantiated');
7
7
  }
8
- Serializable.call(this);
8
+ SqlElement.call(this);
9
9
  };
10
- Operator.prototype = Object.create(Serializable.prototype);
10
+ Operator.prototype = Object.create(SqlElement.prototype);
11
11
  Operator.prototype.constructor = Operator;
package/sql/query.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { EventEmitter } from 'events';
2
- import { Serializable } from '../serializable.js';
2
+ import { SqlElement } from '../serializable.js';
3
3
  import type { GenerateOptions, GenerateResult } from '../types.js';
4
4
  declare interface QueryClass extends EventEmitter {
5
5
  }
6
- declare class QueryClass extends Serializable {
6
+ declare class QueryClass extends SqlElement {
7
7
  protected _comment: Query.Comment[];
8
8
  protected _params?: Record<string, any>;
9
9
  /**
package/sql/query.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import flattenText from 'putil-flattentext';
3
3
  import merge from 'putil-merge';
4
- import { Serializable } from '../serializable.js';
4
+ import { SqlElement } from '../serializable.js';
5
5
  import { SerializeContext } from '../serialize-context.js';
6
- class QueryClass extends Serializable {
6
+ class QueryClass extends SqlElement {
7
7
  /**
8
8
  * Generates Sql script
9
9
  */
@@ -59,7 +59,7 @@ export const Query = function () {
59
59
  if (this.constructor === Query) {
60
60
  throw new TypeError('Query is abstract and cannot be instantiated');
61
61
  }
62
- Serializable.call(this);
62
+ SqlElement.call(this);
63
63
  EventEmitter.call(this);
64
64
  this._comment = [];
65
65
  };
package/sql/select.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { SerializationType } from '../enums.js';
2
- import { Serializable } from '../serializable.js';
2
+ import { SqlElement } from '../serializable.js';
3
3
  import { SerializeContext } from '../serialize-context.js';
4
4
  import { GroupColumn } from './elements/group-column.js';
5
5
  import { Join } from './elements/join.js';
@@ -10,12 +10,12 @@ import { LogicalOperator } from './operators/logical-operator.js';
10
10
  import { Query } from './query.js';
11
11
  import type { Union } from './union.js';
12
12
  declare class SelectClass extends Query {
13
- _tables?: Serializable[];
14
- _columns?: Serializable[];
13
+ _tables?: SqlElement[];
14
+ _columns?: SqlElement[];
15
15
  _joins?: Join[];
16
16
  _where?: LogicalOperator;
17
- _groupBy?: (GroupColumn | Serializable)[];
18
- _orderBy?: (OrderColumn | Serializable)[];
17
+ _groupBy?: (GroupColumn | SqlElement)[];
18
+ _orderBy?: (OrderColumn | SqlElement)[];
19
19
  _limit?: number;
20
20
  _offset?: number;
21
21
  _alias?: string;
@@ -24,7 +24,7 @@ declare class SelectClass extends Query {
24
24
  /**
25
25
  * Adds columns to query.
26
26
  */
27
- addColumn(...column: (string | string[] | Serializable)[]): this;
27
+ addColumn(...column: (string | string[] | SqlElement)[]): this;
28
28
  /**
29
29
  * Defines "from" part of query.
30
30
  */
@@ -36,15 +36,15 @@ declare class SelectClass extends Query {
36
36
  /**
37
37
  * Defines "where" part of query
38
38
  */
39
- where(...condition: (Serializable | Object)[]): this;
39
+ where(...condition: (SqlElement | Object)[]): this;
40
40
  /**
41
41
  * Defines "where" part of query
42
42
  */
43
- groupBy(...field: (string | Serializable)[]): this;
43
+ groupBy(...field: (string | SqlElement)[]): this;
44
44
  /**
45
45
  * Defines "order by" part of query.
46
46
  */
47
- orderBy(...field: (string | Serializable)[]): this;
47
+ orderBy(...field: (string | SqlElement)[]): this;
48
48
  /**
49
49
  * Sets alias for sub-select queries
50
50
  */
@@ -90,8 +90,8 @@ declare class SelectClass extends Query {
90
90
  protected __serializeOrderColumns(ctx: SerializeContext): string;
91
91
  }
92
92
  interface SelectCtor {
93
- new (...column: (string | string[] | Serializable)[]): Select;
94
- (...column: (string | string[] | Serializable)[]): Select;
93
+ new (...column: (string | string[] | SqlElement)[]): Select;
94
+ (...column: (string | string[] | SqlElement)[]): Select;
95
95
  prototype: Select;
96
96
  }
97
97
  export declare const Select: SelectCtor;
package/sql/update.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SerializationType } from '../enums.js';
2
2
  import { printArray } from '../helpers.js';
3
- import { Serializable } from '../serializable.js';
3
+ import { SqlElement } from '../serializable.js';
4
4
  import { isRaw } from '../type-guards.js';
5
5
  import { TableName } from './elements/table-name.js';
6
6
  import { And } from './operators/and.js';
@@ -80,7 +80,7 @@ export const Update = function (tableName, input) {
80
80
  }
81
81
  if (!input ||
82
82
  !((typeof input === 'object' && !Array.isArray(input)) ||
83
- (input instanceof Serializable &&
83
+ (input instanceof SqlElement &&
84
84
  (input._type === SerializationType.SELECT_QUERY ||
85
85
  input._type === SerializationType.RAW)))) {
86
86
  throw new TypeError('Object or Raw instance required as second argument (input) for Update');
package/type-guards.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import type { Serializable } from './serializable.js';
1
+ import type { SqlElement } from './serializable.js';
2
2
  import type { Case, CompOperator, Count, Delete, Field, GroupColumn, Insert, Join, LogicalOperator, OrderColumn, Param, Query, Raw, ReturningColumn, Select, TableName, Update } from './sql/index.js';
3
- export declare function isSerializable(value: any): value is Serializable;
3
+ export declare function isSqlElement(value: any): value is SqlElement;
4
+ export declare function isSerializable(value: any): value is SqlElement;
4
5
  export declare function isQuery(value: any): value is Query;
5
6
  export declare function isRaw(value: any): value is Raw;
6
7
  export declare function isSelect(value: any): value is Select;
package/type-guards.js CHANGED
@@ -1,7 +1,11 @@
1
1
  import { SerializationType } from './enums.js';
2
- export function isSerializable(value) {
2
+ export function isSqlElement(value) {
3
3
  return typeof value === 'object' && typeof value._serialize === 'function';
4
4
  }
5
+ /* Backward compatibility */
6
+ export function isSerializable(value) {
7
+ return isSqlElement(value);
8
+ }
5
9
  export function isQuery(value) {
6
10
  return (isSerializable(value) &&
7
11
  typeof value.generate === 'function' &&