@sqb/builder 4.14.0 → 4.15.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 (63) hide show
  1. package/esm/classes.ns.js +41 -38
  2. package/esm/enums.js +11 -8
  3. package/esm/extensions.js +5 -1
  4. package/esm/helpers.js +4 -1
  5. package/esm/index.js +25 -20
  6. package/esm/op.initializers.js +78 -46
  7. package/esm/query/delete-query.js +15 -11
  8. package/esm/query/insert-query.js +17 -13
  9. package/esm/query/query.js +15 -10
  10. package/esm/query/returning-query.js +12 -8
  11. package/esm/query/select-query.js +32 -28
  12. package/esm/query/union-query.js +8 -4
  13. package/esm/query/update-query.js +18 -14
  14. package/esm/serializable.js +5 -1
  15. package/esm/serialize-context.js +19 -15
  16. package/esm/sql-objects/base-field.js +6 -2
  17. package/esm/sql-objects/case-statement.js +10 -6
  18. package/esm/sql-objects/coalesce-statement.js +8 -4
  19. package/esm/sql-objects/count-statement.js +8 -4
  20. package/esm/sql-objects/expression.js +6 -2
  21. package/esm/sql-objects/field-expression.js +8 -4
  22. package/esm/sql-objects/group-column.js +8 -4
  23. package/esm/sql-objects/join-statement.js +23 -19
  24. package/esm/sql-objects/lower-statement.js +8 -4
  25. package/esm/sql-objects/max-statement.js +8 -4
  26. package/esm/sql-objects/min-statement.js +8 -4
  27. package/esm/sql-objects/operator.js +6 -2
  28. package/esm/sql-objects/operators/comp-operator.js +17 -13
  29. package/esm/sql-objects/operators/logical-operator.js +21 -16
  30. package/esm/sql-objects/operators/op-and.js +8 -4
  31. package/esm/sql-objects/operators/op-between.js +8 -4
  32. package/esm/sql-objects/operators/op-eq.js +8 -4
  33. package/esm/sql-objects/operators/op-exists.js +10 -6
  34. package/esm/sql-objects/operators/op-gt.js +8 -4
  35. package/esm/sql-objects/operators/op-gte.js +8 -4
  36. package/esm/sql-objects/operators/op-ilike.js +8 -4
  37. package/esm/sql-objects/operators/op-in.js +10 -6
  38. package/esm/sql-objects/operators/op-is-not.js +8 -4
  39. package/esm/sql-objects/operators/op-is.js +8 -4
  40. package/esm/sql-objects/operators/op-like.js +8 -4
  41. package/esm/sql-objects/operators/op-lt.js +8 -4
  42. package/esm/sql-objects/operators/op-lte.js +8 -4
  43. package/esm/sql-objects/operators/op-ne.js +8 -4
  44. package/esm/sql-objects/operators/op-not-between.js +8 -4
  45. package/esm/sql-objects/operators/op-not-exists.js +8 -4
  46. package/esm/sql-objects/operators/op-not-ilike.js +8 -4
  47. package/esm/sql-objects/operators/op-not-in.js +8 -4
  48. package/esm/sql-objects/operators/op-not-like.js +8 -4
  49. package/esm/sql-objects/operators/op-not.js +9 -5
  50. package/esm/sql-objects/operators/op-or.js +8 -4
  51. package/esm/sql-objects/order-column.js +8 -4
  52. package/esm/sql-objects/param-expression.js +8 -4
  53. package/esm/sql-objects/raw-statement.js +8 -4
  54. package/esm/sql-objects/returning-column.js +8 -4
  55. package/esm/sql-objects/sequence-getter-statement.js +8 -4
  56. package/esm/sql-objects/string-agg-statement.js +15 -11
  57. package/esm/sql-objects/table-name.js +8 -4
  58. package/esm/sql-objects/upper-statement.js +8 -4
  59. package/esm/sqlobject.initializers.js +131 -101
  60. package/esm/typeguards.js +80 -59
  61. package/esm/types.js +2 -1
  62. package/package.json +23 -17
  63. package/cjs/package.json +0 -3
@@ -1,21 +1,24 @@
1
- import { coerceToInt } from 'putil-varhelpers';
2
- import { SerializationType } from '../enums.js';
3
- import { printArray } from '../helpers.js';
4
- import { FieldExpression } from '../sql-objects/field-expression.js';
5
- import { GroupColumn } from '../sql-objects/group-column.js';
6
- import { OpAnd } from '../sql-objects/operators/op-and.js';
7
- import { OrderColumn } from '../sql-objects/order-column.js';
8
- import { TableName } from '../sql-objects/table-name.js';
9
- import { isJoinStatement, isSerializable } from '../typeguards.js';
10
- import { Query } from './query.js';
11
- export class SelectQuery extends Query {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SelectQuery = void 0;
4
+ const putil_varhelpers_1 = require("putil-varhelpers");
5
+ const enums_js_1 = require("../enums.js");
6
+ const helpers_js_1 = require("../helpers.js");
7
+ const field_expression_js_1 = require("../sql-objects/field-expression.js");
8
+ const group_column_js_1 = require("../sql-objects/group-column.js");
9
+ const op_and_js_1 = require("../sql-objects/operators/op-and.js");
10
+ const order_column_js_1 = require("../sql-objects/order-column.js");
11
+ const table_name_js_1 = require("../sql-objects/table-name.js");
12
+ const typeguards_js_1 = require("../typeguards.js");
13
+ const query_js_1 = require("./query.js");
14
+ class SelectQuery extends query_js_1.Query {
12
15
  constructor(...column) {
13
16
  super();
14
17
  if (column.length)
15
18
  this.addColumn(...column);
16
19
  }
17
20
  get _type() {
18
- return SerializationType.SELECT_QUERY;
21
+ return enums_js_1.SerializationType.SELECT_QUERY;
19
22
  }
20
23
  /**
21
24
  * Adds columns to query.
@@ -29,7 +32,7 @@ export class SelectQuery extends Query {
29
32
  if (Array.isArray(arg))
30
33
  self.addColumn(...arg);
31
34
  else
32
- this._columns.push(isSerializable(arg) ? arg : new FieldExpression(arg));
35
+ this._columns.push((0, typeguards_js_1.isSerializable)(arg) ? arg : new field_expression_js_1.FieldExpression(arg));
33
36
  }
34
37
  return this;
35
38
  }
@@ -41,7 +44,7 @@ export class SelectQuery extends Query {
41
44
  for (const arg of table) {
42
45
  if (!arg)
43
46
  continue;
44
- this._tables.push(typeof arg === 'string' ? new TableName(arg) : arg);
47
+ this._tables.push(typeof arg === 'string' ? new table_name_js_1.TableName(arg) : arg);
45
48
  }
46
49
  return this;
47
50
  }
@@ -53,7 +56,7 @@ export class SelectQuery extends Query {
53
56
  for (const arg of join) {
54
57
  if (!arg)
55
58
  continue;
56
- if (!isJoinStatement(arg))
59
+ if (!(0, typeguards_js_1.isJoinStatement)(arg))
57
60
  throw new TypeError('Join statement required');
58
61
  this._joins.push(arg);
59
62
  }
@@ -63,7 +66,7 @@ export class SelectQuery extends Query {
63
66
  * Defines "where" part of query
64
67
  */
65
68
  where(...condition) {
66
- this._where = this._where || new OpAnd();
69
+ this._where = this._where || new op_and_js_1.OpAnd();
67
70
  this._where.add(...condition);
68
71
  return this;
69
72
  }
@@ -75,7 +78,7 @@ export class SelectQuery extends Query {
75
78
  for (const arg of field) {
76
79
  if (!arg)
77
80
  continue;
78
- this._groupBy.push(typeof arg === 'string' ? new GroupColumn(arg) : arg);
81
+ this._groupBy.push(typeof arg === 'string' ? new group_column_js_1.GroupColumn(arg) : arg);
79
82
  }
80
83
  return this;
81
84
  }
@@ -87,7 +90,7 @@ export class SelectQuery extends Query {
87
90
  for (const arg of field) {
88
91
  if (!arg)
89
92
  continue;
90
- this._orderBy.push(typeof arg === 'string' ? new OrderColumn(arg) : arg);
93
+ this._orderBy.push(typeof arg === 'string' ? new order_column_js_1.OrderColumn(arg) : arg);
91
94
  }
92
95
  return this;
93
96
  }
@@ -102,14 +105,14 @@ export class SelectQuery extends Query {
102
105
  * Sets limit for query
103
106
  */
104
107
  limit(limit) {
105
- this._limit = coerceToInt(limit);
108
+ this._limit = (0, putil_varhelpers_1.coerceToInt)(limit);
106
109
  return this;
107
110
  }
108
111
  /**
109
112
  * Sets offset for query
110
113
  */
111
114
  offset(offset) {
112
- this._offset = coerceToInt(offset);
115
+ this._offset = (0, putil_varhelpers_1.coerceToInt)(offset);
113
116
  return this;
114
117
  }
115
118
  /**
@@ -189,7 +192,7 @@ export class SelectQuery extends Query {
189
192
  }
190
193
  }
191
194
  }
192
- return ctx.serialize(SerializationType.SELECT_QUERY_COLUMNS, arr, () => printArray(arr) || '*');
195
+ return ctx.serialize(enums_js_1.SerializationType.SELECT_QUERY_COLUMNS, arr, () => (0, helpers_js_1.printArray)(arr) || '*');
193
196
  }
194
197
  /**
195
198
  *
@@ -211,7 +214,7 @@ export class SelectQuery extends Query {
211
214
  }
212
215
  }
213
216
  }
214
- return ctx.serialize(SerializationType.SELECT_QUERY_FROM, arr, () => {
217
+ return ctx.serialize(enums_js_1.SerializationType.SELECT_QUERY_FROM, arr, () => {
215
218
  const s = arr.join(',');
216
219
  return s ? 'from' + (s.substring(0, 1) !== '\n' ? ' ' : '') + s : '';
217
220
  });
@@ -229,7 +232,7 @@ export class SelectQuery extends Query {
229
232
  arr.push(s);
230
233
  }
231
234
  }
232
- return ctx.serialize(SerializationType.SELECT_QUERY_JOIN, arr, () => arr.join('\n'));
235
+ return ctx.serialize(enums_js_1.SerializationType.SELECT_QUERY_JOIN, arr, () => arr.join('\n'));
233
236
  }
234
237
  /**
235
238
  *
@@ -238,7 +241,7 @@ export class SelectQuery extends Query {
238
241
  if (!this._where)
239
242
  return '';
240
243
  const s = this._where._serialize(ctx);
241
- return ctx.serialize(SerializationType.CONDITIONS_BLOCK, s, () =>
244
+ return ctx.serialize(enums_js_1.SerializationType.CONDITIONS_BLOCK, s, () =>
242
245
  /* istanbul ignore next */
243
246
  s ? 'where ' + s : '');
244
247
  }
@@ -255,8 +258,8 @@ export class SelectQuery extends Query {
255
258
  arr.push(s);
256
259
  }
257
260
  }
258
- return ctx.serialize(SerializationType.SELECT_QUERY_GROUPBY, arr, () => {
259
- const s = printArray(arr);
261
+ return ctx.serialize(enums_js_1.SerializationType.SELECT_QUERY_GROUPBY, arr, () => {
262
+ const s = (0, helpers_js_1.printArray)(arr);
260
263
  return s ? 'group by ' + s : '';
261
264
  });
262
265
  }
@@ -270,9 +273,10 @@ export class SelectQuery extends Query {
270
273
  arr.push(s);
271
274
  }
272
275
  }
273
- return ctx.serialize(SerializationType.SELECT_QUERY_ORDERBY, arr, () => {
274
- const s = printArray(arr);
276
+ return ctx.serialize(enums_js_1.SerializationType.SELECT_QUERY_ORDERBY, arr, () => {
277
+ const s = (0, helpers_js_1.printArray)(arr);
275
278
  return s ? 'order by ' + s : '';
276
279
  });
277
280
  }
278
281
  }
282
+ exports.SelectQuery = SelectQuery;
@@ -1,13 +1,16 @@
1
- import { SerializationType } from '../enums.js';
2
- import { Query } from './query.js';
3
- export class UnionQuery extends Query {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnionQuery = void 0;
4
+ const enums_js_1 = require("../enums.js");
5
+ const query_js_1 = require("./query.js");
6
+ class UnionQuery extends query_js_1.Query {
4
7
  constructor(queries, unionType) {
5
8
  super();
6
9
  this._queries = queries;
7
10
  this._unionType = unionType;
8
11
  }
9
12
  get _type() {
10
- return SerializationType.UNION_QUERY;
13
+ return enums_js_1.SerializationType.UNION_QUERY;
11
14
  }
12
15
  /**
13
16
  * Performs serialization
@@ -24,3 +27,4 @@ export class UnionQuery extends Query {
24
27
  return o.queries.join(o.unionType === 'all' ? '\nUNION ALL\n' : '\nUNION\n');
25
28
  }
26
29
  }
30
+ exports.UnionQuery = UnionQuery;
@@ -1,29 +1,32 @@
1
- import { SerializationType } from '../enums.js';
2
- import { printArray } from '../helpers.js';
3
- import { OpAnd } from '../sql-objects/operators/op-and.js';
4
- import { TableName } from '../sql-objects/table-name.js';
5
- import { isRawStatement } from '../typeguards.js';
6
- import { ReturningQuery } from './returning-query.js';
7
- export class UpdateQuery extends ReturningQuery {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateQuery = void 0;
4
+ const enums_js_1 = require("../enums.js");
5
+ const helpers_js_1 = require("../helpers.js");
6
+ const op_and_js_1 = require("../sql-objects/operators/op-and.js");
7
+ const table_name_js_1 = require("../sql-objects/table-name.js");
8
+ const typeguards_js_1 = require("../typeguards.js");
9
+ const returning_query_js_1 = require("./returning-query.js");
10
+ class UpdateQuery extends returning_query_js_1.ReturningQuery {
8
11
  constructor(tableName, input) {
9
12
  super();
10
- if (!tableName || !(typeof tableName === 'string' || isRawStatement(tableName))) {
13
+ if (!tableName || !(typeof tableName === 'string' || (0, typeguards_js_1.isRawStatement)(tableName))) {
11
14
  throw new TypeError('String or Raw instance required as first argument (tableName) for UpdateQuery');
12
15
  }
13
16
  if (!input || !((typeof input === 'object' && !Array.isArray(input)) || input.isSelect)) {
14
17
  throw new TypeError('Object or Raw instance required as second argument (input) for UpdateQuery');
15
18
  }
16
- this._table = typeof tableName === 'string' ? new TableName(tableName) : tableName;
19
+ this._table = typeof tableName === 'string' ? new table_name_js_1.TableName(tableName) : tableName;
17
20
  this._input = input;
18
21
  }
19
22
  get _type() {
20
- return SerializationType.UPDATE_QUERY;
23
+ return enums_js_1.SerializationType.UPDATE_QUERY;
21
24
  }
22
25
  /**
23
26
  * Defines "where" part of query
24
27
  */
25
28
  where(...operator) {
26
- this._where = this._where || new OpAnd();
29
+ this._where = this._where || new op_and_js_1.OpAnd();
27
30
  this._where.add(...operator);
28
31
  return this;
29
32
  }
@@ -57,9 +60,9 @@ export class UpdateQuery extends ReturningQuery {
57
60
  value,
58
61
  });
59
62
  }
60
- return ctx.serialize(SerializationType.UPDATE_QUERY_VALUES, arr, () => {
63
+ return ctx.serialize(enums_js_1.SerializationType.UPDATE_QUERY_VALUES, arr, () => {
61
64
  const a = arr.map(o => o.field + ' = ' + o.value);
62
- return printArray(a, ',');
65
+ return (0, helpers_js_1.printArray)(a, ',');
63
66
  });
64
67
  }
65
68
  /**
@@ -69,8 +72,9 @@ export class UpdateQuery extends ReturningQuery {
69
72
  if (!this._where)
70
73
  return '';
71
74
  const s = this._where._serialize(ctx);
72
- return ctx.serialize(SerializationType.CONDITIONS_BLOCK, s, () =>
75
+ return ctx.serialize(enums_js_1.SerializationType.CONDITIONS_BLOCK, s, () =>
73
76
  /* istanbul ignore next */
74
77
  s ? 'where ' + s : '');
75
78
  }
76
79
  }
80
+ exports.UpdateQuery = UpdateQuery;
@@ -1,2 +1,6 @@
1
- export class Serializable {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Serializable = void 0;
4
+ class Serializable {
2
5
  }
6
+ exports.Serializable = Serializable;
@@ -1,8 +1,11 @@
1
- import { SerializationType } from './enums.js';
2
- import { SerializerRegistry } from './extensions.js';
3
- import { Serializable } from './serializable.js';
4
- import { isLogicalOperator, isQuery, isSerializable } from './typeguards.js';
5
- export class SerializeContext {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SerializeContext = void 0;
4
+ const enums_js_1 = require("./enums.js");
5
+ const extensions_js_1 = require("./extensions.js");
6
+ const serializable_js_1 = require("./serializable.js");
7
+ const typeguards_js_1 = require("./typeguards.js");
8
+ class SerializeContext {
6
9
  constructor(opts) {
7
10
  this.reservedWords = [
8
11
  'schema',
@@ -76,7 +79,7 @@ export class SerializeContext {
76
79
  return s;
77
80
  }
78
81
  }
79
- for (const ext of SerializerRegistry.items()) {
82
+ for (const ext of extensions_js_1.SerializerRegistry.items()) {
80
83
  if (ext.dialect === this.dialect && ext.serialize) {
81
84
  const s = ext.serialize(this, type, o, fallback);
82
85
  if (s != null)
@@ -93,28 +96,28 @@ export class SerializeContext {
93
96
  return 'null';
94
97
  if (Array.isArray(v)) {
95
98
  const vv = v.map(x => this.anyToSQL(x));
96
- return this.serialize(SerializationType.ARRAY, vv, () => '(' + vv.join(',')) + ')';
99
+ return this.serialize(enums_js_1.SerializationType.ARRAY, vv, () => '(' + vv.join(',')) + ')';
97
100
  }
98
101
  if (typeof v === 'object') {
99
- if (isSerializable(v)) {
102
+ if ((0, typeguards_js_1.isSerializable)(v)) {
100
103
  const s = v._serialize(this);
101
- return s ? (isQuery(v) || isLogicalOperator(v) ? '(' + s + ')' : s) : /* istanbul ignore next */ '';
104
+ return s ? ((0, typeguards_js_1.isQuery)(v) || (0, typeguards_js_1.isLogicalOperator)(v) ? '(' + s + ')' : s) : /* istanbul ignore next */ '';
102
105
  }
103
106
  if (v instanceof Date) {
104
- return this.serialize(SerializationType.DATE_VALUE, v, () => this.dateToSQL(v));
107
+ return this.serialize(enums_js_1.SerializationType.DATE_VALUE, v, () => this.dateToSQL(v));
105
108
  }
106
109
  return this.stringToSQL(JSON.stringify(v));
107
110
  }
108
111
  if (typeof v === 'string') {
109
- return this.serialize(SerializationType.STRING_VALUE, v, () => this.stringToSQL(v));
112
+ return this.serialize(enums_js_1.SerializationType.STRING_VALUE, v, () => this.stringToSQL(v));
110
113
  }
111
114
  if (typeof v === 'boolean') {
112
- return this.serialize(SerializationType.BOOLEAN_VALUE, v, () => this.booleanToSQL(v));
115
+ return this.serialize(enums_js_1.SerializationType.BOOLEAN_VALUE, v, () => this.booleanToSQL(v));
113
116
  }
114
117
  if (typeof v === 'number') {
115
- return this.serialize(SerializationType.NUMBER_VALUE, v, () => this.numberToSQL(v));
118
+ return this.serialize(enums_js_1.SerializationType.NUMBER_VALUE, v, () => this.numberToSQL(v));
116
119
  }
117
- if (v instanceof Serializable)
120
+ if (v instanceof serializable_js_1.Serializable)
118
121
  return v._serialize(this);
119
122
  return v;
120
123
  }
@@ -160,7 +163,7 @@ export class SerializeContext {
160
163
  return false;
161
164
  if (this.reservedWords.includes(s.toLowerCase()))
162
165
  return true;
163
- for (const ext of SerializerRegistry.items()) {
166
+ for (const ext of extensions_js_1.SerializerRegistry.items()) {
164
167
  if (ext.dialect === this.dialect && ext.isReservedWord) {
165
168
  if (ext.isReservedWord(this, s))
166
169
  return true;
@@ -176,3 +179,4 @@ export class SerializeContext {
176
179
  return s;
177
180
  }
178
181
  }
182
+ exports.SerializeContext = SerializeContext;
@@ -1,7 +1,11 @@
1
- import { Expression } from './expression.js';
2
- export class BaseField extends Expression {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseField = void 0;
4
+ const expression_js_1 = require("./expression.js");
5
+ class BaseField extends expression_js_1.Expression {
3
6
  constructor() {
4
7
  super(...arguments);
5
8
  this._field = '';
6
9
  }
7
10
  }
11
+ exports.BaseField = BaseField;
@@ -1,20 +1,23 @@
1
- import { SerializationType } from '../enums.js';
2
- import { Serializable } from '../serializable.js';
3
- import { OpAnd } from './operators/op-and.js';
4
- export class CaseStatement extends Serializable {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CaseStatement = void 0;
4
+ const enums_js_1 = require("../enums.js");
5
+ const serializable_js_1 = require("../serializable.js");
6
+ const op_and_js_1 = require("./operators/op-and.js");
7
+ class CaseStatement extends serializable_js_1.Serializable {
5
8
  constructor() {
6
9
  super();
7
10
  this._expressions = [];
8
11
  }
9
12
  get _type() {
10
- return SerializationType.CASE_STATEMENT;
13
+ return enums_js_1.SerializationType.CASE_STATEMENT;
11
14
  }
12
15
  /**
13
16
  * Defines "when" part of Case expression.
14
17
  */
15
18
  when(...condition) {
16
19
  if (condition.length)
17
- this._condition = new OpAnd(...condition);
20
+ this._condition = new op_and_js_1.OpAnd(...condition);
18
21
  else
19
22
  this._condition = undefined;
20
23
  return this;
@@ -79,3 +82,4 @@ export class CaseStatement extends Serializable {
79
82
  return out;
80
83
  }
81
84
  }
85
+ exports.CaseStatement = CaseStatement;
@@ -1,12 +1,15 @@
1
- import { SerializationType } from '../enums.js';
2
- import { Serializable } from '../serializable.js';
3
- export class CoalesceStatement extends Serializable {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoalesceStatement = void 0;
4
+ const enums_js_1 = require("../enums.js");
5
+ const serializable_js_1 = require("../serializable.js");
6
+ class CoalesceStatement extends serializable_js_1.Serializable {
4
7
  constructor(...expressions) {
5
8
  super();
6
9
  this._expressions = expressions;
7
10
  }
8
11
  get _type() {
9
- return SerializationType.COALESCE_STATEMENT;
12
+ return enums_js_1.SerializationType.COALESCE_STATEMENT;
10
13
  }
11
14
  /**
12
15
  * Sets alias to case expression.
@@ -37,3 +40,4 @@ export class CoalesceStatement extends Serializable {
37
40
  return 'coalesce(' + o.expressions.join(', ') + ')' + (this._alias ? ' ' + this._alias : '');
38
41
  }
39
42
  }
43
+ exports.CoalesceStatement = CoalesceStatement;
@@ -1,8 +1,11 @@
1
- import { SerializationType } from '../enums.js';
2
- import { Serializable } from '../serializable.js';
3
- export class CountStatement extends Serializable {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CountStatement = void 0;
4
+ const enums_js_1 = require("../enums.js");
5
+ const serializable_js_1 = require("../serializable.js");
6
+ class CountStatement extends serializable_js_1.Serializable {
4
7
  get _type() {
5
- return SerializationType.COUNT_STATEMENT;
8
+ return enums_js_1.SerializationType.COUNT_STATEMENT;
6
9
  }
7
10
  /**
8
11
  * Sets alias to case expression.
@@ -30,3 +33,4 @@ export class CountStatement extends Serializable {
30
33
  return 'count(*)';
31
34
  }
32
35
  }
36
+ exports.CountStatement = CountStatement;
@@ -1,3 +1,7 @@
1
- import { Serializable } from '../serializable.js';
2
- export class Expression extends Serializable {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Expression = void 0;
4
+ const serializable_js_1 = require("../serializable.js");
5
+ class Expression extends serializable_js_1.Serializable {
3
6
  }
7
+ exports.Expression = Expression;
@@ -1,7 +1,10 @@
1
- import { SerializationType } from '../enums.js';
2
- import { BaseField } from './base-field.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldExpression = void 0;
4
+ const enums_js_1 = require("../enums.js");
5
+ const base_field_js_1 = require("./base-field.js");
3
6
  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 {
7
+ class FieldExpression extends base_field_js_1.BaseField {
5
8
  constructor(arg0, arg1, arg2) {
6
9
  super();
7
10
  let expression;
@@ -28,7 +31,7 @@ export class FieldExpression extends BaseField {
28
31
  this._alias = this._field !== '*' ? m[3] : '';
29
32
  }
30
33
  get _type() {
31
- return SerializationType.FIELD_NAME;
34
+ return enums_js_1.SerializationType.FIELD_NAME;
32
35
  }
33
36
  _serialize(ctx) {
34
37
  const o = {
@@ -46,3 +49,4 @@ export class FieldExpression extends BaseField {
46
49
  });
47
50
  }
48
51
  }
52
+ exports.FieldExpression = FieldExpression;
@@ -1,7 +1,10 @@
1
- import { SerializationType } from '../enums.js';
2
- import { BaseField } from './base-field.js';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupColumn = void 0;
4
+ const enums_js_1 = require("../enums.js");
5
+ const base_field_js_1 = require("./base-field.js");
3
6
  const GROUP_COLUMN_PATTERN = /^((?:[a-zA-Z][\w$]*\.){0,2})([\w$]*)$/;
4
- export class GroupColumn extends BaseField {
7
+ class GroupColumn extends base_field_js_1.BaseField {
5
8
  constructor(value) {
6
9
  super();
7
10
  const m = value.match(GROUP_COLUMN_PATTERN);
@@ -16,7 +19,7 @@ export class GroupColumn extends BaseField {
16
19
  }
17
20
  }
18
21
  get _type() {
19
- return SerializationType.GROUP_COLUMN;
22
+ return enums_js_1.SerializationType.GROUP_COLUMN;
20
23
  }
21
24
  _serialize(ctx) {
22
25
  const o = {
@@ -30,3 +33,4 @@ export class GroupColumn extends BaseField {
30
33
  (o.isReservedWord ? '"' + this._field + '"' : this._field));
31
34
  }
32
35
  }
36
+ exports.GroupColumn = GroupColumn;
@@ -1,21 +1,24 @@
1
- import { JoinType, SerializationType } from '../enums.js';
2
- import { Serializable } from '../serializable.js';
3
- import { isRawStatement, isSelectQuery, isTableName } from '../typeguards.js';
4
- import { OpAnd } from './operators/op-and.js';
5
- import { TableName } from './table-name.js';
6
- export class JoinStatement extends Serializable {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JoinStatement = void 0;
4
+ const enums_js_1 = require("../enums.js");
5
+ const serializable_js_1 = require("../serializable.js");
6
+ const typeguards_js_1 = require("../typeguards.js");
7
+ const op_and_js_1 = require("./operators/op-and.js");
8
+ const table_name_js_1 = require("./table-name.js");
9
+ class JoinStatement extends serializable_js_1.Serializable {
7
10
  constructor(joinType, table) {
8
11
  super();
9
- this._conditions = new OpAnd();
12
+ this._conditions = new op_and_js_1.OpAnd();
10
13
  // noinspection SuspiciousTypeOfGuard
11
- if (!(isSelectQuery(table) || isRawStatement(table) || isTableName(table) || typeof table === 'string')) {
14
+ if (!((0, typeguards_js_1.isSelectQuery)(table) || (0, typeguards_js_1.isRawStatement)(table) || (0, typeguards_js_1.isTableName)(table) || typeof table === 'string')) {
12
15
  throw new TypeError('Table name, select query or raw object required for Join');
13
16
  }
14
17
  this._joinType = joinType;
15
- this._table = typeof table === 'string' ? new TableName(table) : table;
18
+ this._table = typeof table === 'string' ? new table_name_js_1.TableName(table) : table;
16
19
  }
17
20
  get _type() {
18
- return SerializationType.JOIN;
21
+ return enums_js_1.SerializationType.JOIN;
19
22
  }
20
23
  on(...conditions) {
21
24
  this._conditions.add(...conditions);
@@ -30,25 +33,25 @@ export class JoinStatement extends Serializable {
30
33
  return ctx.serialize(this._type, o, () => {
31
34
  let out;
32
35
  switch (this._joinType) {
33
- case JoinType.LEFT:
36
+ case enums_js_1.JoinType.LEFT:
34
37
  out = 'left join';
35
38
  break;
36
- case JoinType.LEFT_OUTER:
39
+ case enums_js_1.JoinType.LEFT_OUTER:
37
40
  out = 'left outer join';
38
41
  break;
39
- case JoinType.RIGHT:
42
+ case enums_js_1.JoinType.RIGHT:
40
43
  out = 'right join';
41
44
  break;
42
- case JoinType.RIGHT_OUTER:
45
+ case enums_js_1.JoinType.RIGHT_OUTER:
43
46
  out = 'right outer join';
44
47
  break;
45
- case JoinType.OUTER:
48
+ case enums_js_1.JoinType.OUTER:
46
49
  out = 'outer join';
47
50
  break;
48
- case JoinType.FULL_OUTER:
51
+ case enums_js_1.JoinType.FULL_OUTER:
49
52
  out = 'full outer join';
50
53
  break;
51
- case JoinType.CROSS:
54
+ case enums_js_1.JoinType.CROSS:
52
55
  out = 'cross join';
53
56
  break;
54
57
  default:
@@ -56,7 +59,7 @@ export class JoinStatement extends Serializable {
56
59
  break;
57
60
  }
58
61
  const lf = o.table.length > 40;
59
- if (isSelectQuery(this._table)) {
62
+ if ((0, typeguards_js_1.isSelectQuery)(this._table)) {
60
63
  const alias = this._table._alias;
61
64
  if (!alias)
62
65
  throw new Error('Alias required for sub-select in Join');
@@ -72,8 +75,9 @@ export class JoinStatement extends Serializable {
72
75
  __serializeConditions(ctx, join) {
73
76
  if (join._conditions._items.length) {
74
77
  const s = join._conditions._serialize(ctx);
75
- return ctx.serialize(SerializationType.JOIN_CONDITIONS, s, () => (s ? 'on ' + s : ''));
78
+ return ctx.serialize(enums_js_1.SerializationType.JOIN_CONDITIONS, s, () => (s ? 'on ' + s : ''));
76
79
  }
77
80
  return '';
78
81
  }
79
82
  }
83
+ exports.JoinStatement = JoinStatement;
@@ -1,12 +1,15 @@
1
- import { SerializationType } from '../enums.js';
2
- import { Serializable } from '../serializable.js';
3
- export class LowerStatement extends Serializable {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LowerStatement = void 0;
4
+ const enums_js_1 = require("../enums.js");
5
+ const serializable_js_1 = require("../serializable.js");
6
+ class LowerStatement extends serializable_js_1.Serializable {
4
7
  constructor(expression) {
5
8
  super();
6
9
  this._expression = expression;
7
10
  }
8
11
  get _type() {
9
- return SerializationType.LOWER_STATEMENT;
12
+ return enums_js_1.SerializationType.LOWER_STATEMENT;
10
13
  }
11
14
  /**
12
15
  * Sets alias to case expression.
@@ -32,3 +35,4 @@ export class LowerStatement extends Serializable {
32
35
  return 'lower(' + o + ')' + (this._alias ? ' ' + this._alias : '');
33
36
  }
34
37
  }
38
+ exports.LowerStatement = LowerStatement;
@@ -1,12 +1,15 @@
1
- import { SerializationType } from '../enums.js';
2
- import { Serializable } from '../serializable.js';
3
- export class MaxStatement extends Serializable {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MaxStatement = void 0;
4
+ const enums_js_1 = require("../enums.js");
5
+ const serializable_js_1 = require("../serializable.js");
6
+ class MaxStatement extends serializable_js_1.Serializable {
4
7
  constructor(expression) {
5
8
  super();
6
9
  this._expression = expression;
7
10
  }
8
11
  get _type() {
9
- return SerializationType.MAX_STATEMENT;
12
+ return enums_js_1.SerializationType.MAX_STATEMENT;
10
13
  }
11
14
  /**
12
15
  * Sets alias to case expression.
@@ -32,3 +35,4 @@ export class MaxStatement extends Serializable {
32
35
  return 'max(' + o + ')' + (this._alias ? ' ' + this._alias : '');
33
36
  }
34
37
  }
38
+ exports.MaxStatement = MaxStatement;