@sqb/builder 4.20.7 → 4.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -24
- package/{types/sql-objects → sql-objects}/join-statement.d.ts +4 -4
- package/{types/typeguards.d.ts → typeguards.d.ts} +4 -3
- package/{esm/typeguards.js → typeguards.js} +4 -4
- package/cjs/classes.ns.js +0 -41
- package/cjs/enums.js +0 -102
- package/cjs/extensions.js +0 -38
- package/cjs/helpers.js +0 -30
- package/cjs/index.js +0 -25
- package/cjs/op.initializers.js +0 -163
- package/cjs/package.json +0 -3
- package/cjs/query/delete-query.js +0 -57
- package/cjs/query/insert-query.js +0 -86
- package/cjs/query/query.js +0 -41
- package/cjs/query/returning-query.js +0 -46
- package/cjs/query/select-query.js +0 -297
- package/cjs/query/union-query.js +0 -32
- package/cjs/query/update-query.js +0 -86
- package/cjs/serializable.js +0 -6
- package/cjs/serialize-context.js +0 -203
- package/cjs/sql-objects/base-field.js +0 -11
- package/cjs/sql-objects/case-statement.js +0 -91
- package/cjs/sql-objects/coalesce-statement.js +0 -48
- package/cjs/sql-objects/count-statement.js +0 -37
- package/cjs/sql-objects/expression.js +0 -10
- package/cjs/sql-objects/field-expression.js +0 -54
- package/cjs/sql-objects/group-column.js +0 -36
- package/cjs/sql-objects/join-statement.js +0 -94
- package/cjs/sql-objects/lower-statement.js +0 -40
- package/cjs/sql-objects/max-statement.js +0 -40
- package/cjs/sql-objects/min-statement.js +0 -40
- package/cjs/sql-objects/operator.js +0 -7
- package/cjs/sql-objects/operators/comp-operator.js +0 -89
- package/cjs/sql-objects/operators/logical-operator.js +0 -86
- package/cjs/sql-objects/operators/op-and.js +0 -9
- package/cjs/sql-objects/operators/op-between.js +0 -40
- package/cjs/sql-objects/operators/op-eq.js +0 -13
- package/cjs/sql-objects/operators/op-exists.js +0 -31
- package/cjs/sql-objects/operators/op-gt.js +0 -13
- package/cjs/sql-objects/operators/op-gte.js +0 -13
- package/cjs/sql-objects/operators/op-ilike.js +0 -10
- package/cjs/sql-objects/operators/op-in.js +0 -19
- package/cjs/sql-objects/operators/op-is-not.js +0 -13
- package/cjs/sql-objects/operators/op-is.js +0 -13
- package/cjs/sql-objects/operators/op-like.js +0 -20
- package/cjs/sql-objects/operators/op-lt.js +0 -13
- package/cjs/sql-objects/operators/op-lte.js +0 -13
- package/cjs/sql-objects/operators/op-ne.js +0 -13
- package/cjs/sql-objects/operators/op-not-between.js +0 -10
- package/cjs/sql-objects/operators/op-not-exists.js +0 -10
- package/cjs/sql-objects/operators/op-not-ilike.js +0 -10
- package/cjs/sql-objects/operators/op-not-in.js +0 -10
- package/cjs/sql-objects/operators/op-not-like.js +0 -10
- package/cjs/sql-objects/operators/op-not.js +0 -21
- package/cjs/sql-objects/operators/op-or.js +0 -9
- package/cjs/sql-objects/order-column.js +0 -43
- package/cjs/sql-objects/param-expression.js +0 -56
- package/cjs/sql-objects/raw-statement.js +0 -19
- package/cjs/sql-objects/returning-column.js +0 -31
- package/cjs/sql-objects/sequence-getter-statement.js +0 -54
- package/cjs/sql-objects/string-agg-statement.js +0 -88
- package/cjs/sql-objects/table-name.js +0 -35
- package/cjs/sql-objects/upper-statement.js +0 -40
- package/cjs/sqlobject.initializers.js +0 -141
- package/cjs/typeguards.js +0 -85
- package/cjs/types.js +0 -2
- package/esm/package.json +0 -3
- package/types/index.d.cts +0 -20
- /package/{types/classes.ns.d.ts → classes.ns.d.ts} +0 -0
- /package/{esm/classes.ns.js → classes.ns.js} +0 -0
- /package/{types/enums.d.ts → enums.d.ts} +0 -0
- /package/{esm/enums.js → enums.js} +0 -0
- /package/{types/extensions.d.ts → extensions.d.ts} +0 -0
- /package/{esm/extensions.js → extensions.js} +0 -0
- /package/{types/helpers.d.ts → helpers.d.ts} +0 -0
- /package/{esm/helpers.js → helpers.js} +0 -0
- /package/{types/index.d.ts → index.d.ts} +0 -0
- /package/{esm/index.js → index.js} +0 -0
- /package/{types/op.initializers.d.ts → op.initializers.d.ts} +0 -0
- /package/{esm/op.initializers.js → op.initializers.js} +0 -0
- /package/{types/query → query}/delete-query.d.ts +0 -0
- /package/{esm/query → query}/delete-query.js +0 -0
- /package/{types/query → query}/insert-query.d.ts +0 -0
- /package/{esm/query → query}/insert-query.js +0 -0
- /package/{types/query → query}/query.d.ts +0 -0
- /package/{esm/query → query}/query.js +0 -0
- /package/{types/query → query}/returning-query.d.ts +0 -0
- /package/{esm/query → query}/returning-query.js +0 -0
- /package/{types/query → query}/select-query.d.ts +0 -0
- /package/{esm/query → query}/select-query.js +0 -0
- /package/{types/query → query}/union-query.d.ts +0 -0
- /package/{esm/query → query}/union-query.js +0 -0
- /package/{types/query → query}/update-query.d.ts +0 -0
- /package/{esm/query → query}/update-query.js +0 -0
- /package/{types/serializable.d.ts → serializable.d.ts} +0 -0
- /package/{esm/serializable.js → serializable.js} +0 -0
- /package/{types/serialize-context.d.ts → serialize-context.d.ts} +0 -0
- /package/{esm/serialize-context.js → serialize-context.js} +0 -0
- /package/{types/sql-objects → sql-objects}/base-field.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/base-field.js +0 -0
- /package/{types/sql-objects → sql-objects}/case-statement.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/case-statement.js +0 -0
- /package/{types/sql-objects → sql-objects}/coalesce-statement.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/coalesce-statement.js +0 -0
- /package/{types/sql-objects → sql-objects}/count-statement.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/count-statement.js +0 -0
- /package/{types/sql-objects → sql-objects}/expression.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/expression.js +0 -0
- /package/{types/sql-objects → sql-objects}/field-expression.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/field-expression.js +0 -0
- /package/{types/sql-objects → sql-objects}/group-column.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/group-column.js +0 -0
- /package/{esm/sql-objects → sql-objects}/join-statement.js +0 -0
- /package/{types/sql-objects → sql-objects}/lower-statement.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/lower-statement.js +0 -0
- /package/{types/sql-objects → sql-objects}/max-statement.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/max-statement.js +0 -0
- /package/{types/sql-objects → sql-objects}/min-statement.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/min-statement.js +0 -0
- /package/{types/sql-objects → sql-objects}/operator.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operator.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/comp-operator.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/comp-operator.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/logical-operator.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/logical-operator.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-and.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-and.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-between.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-between.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-eq.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-eq.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-exists.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-exists.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-gt.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-gt.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-gte.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-gte.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-ilike.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-ilike.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-in.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-in.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-is-not.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-is-not.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-is.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-is.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-like.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-like.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-lt.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-lt.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-lte.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-lte.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-ne.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-ne.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-not-between.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-not-between.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-not-exists.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-not-exists.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-not-ilike.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-not-ilike.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-not-in.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-not-in.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-not-like.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-not-like.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-not.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-not.js +0 -0
- /package/{types/sql-objects → sql-objects}/operators/op-or.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/operators/op-or.js +0 -0
- /package/{types/sql-objects → sql-objects}/order-column.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/order-column.js +0 -0
- /package/{types/sql-objects → sql-objects}/param-expression.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/param-expression.js +0 -0
- /package/{types/sql-objects → sql-objects}/raw-statement.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/raw-statement.js +0 -0
- /package/{types/sql-objects → sql-objects}/returning-column.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/returning-column.js +0 -0
- /package/{types/sql-objects → sql-objects}/sequence-getter-statement.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/sequence-getter-statement.js +0 -0
- /package/{types/sql-objects → sql-objects}/string-agg-statement.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/string-agg-statement.js +0 -0
- /package/{types/sql-objects → sql-objects}/table-name.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/table-name.js +0 -0
- /package/{types/sql-objects → sql-objects}/upper-statement.d.ts +0 -0
- /package/{esm/sql-objects → sql-objects}/upper-statement.js +0 -0
- /package/{types/sqlobject.initializers.d.ts → sqlobject.initializers.d.ts} +0 -0
- /package/{esm/sqlobject.initializers.js → sqlobject.initializers.js} +0 -0
- /package/{types/types.d.ts → types.d.ts} +0 -0
- /package/{esm/types.js → types.js} +0 -0
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParamExpression = void 0;
|
|
4
|
-
const enums_js_1 = require("../enums.js");
|
|
5
|
-
const serializable_js_1 = require("../serializable.js");
|
|
6
|
-
class ParamExpression extends serializable_js_1.Serializable {
|
|
7
|
-
_name;
|
|
8
|
-
_dataType;
|
|
9
|
-
_isArray;
|
|
10
|
-
constructor(arg) {
|
|
11
|
-
super();
|
|
12
|
-
if (typeof arg === 'object') {
|
|
13
|
-
this._name = arg.name;
|
|
14
|
-
this._dataType = arg.dataType;
|
|
15
|
-
this._isArray = arg.isArray;
|
|
16
|
-
}
|
|
17
|
-
else
|
|
18
|
-
this._name = arg;
|
|
19
|
-
}
|
|
20
|
-
get _type() {
|
|
21
|
-
return enums_js_1.SerializationType.EXTERNAL_PARAMETER;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Performs serialization
|
|
25
|
-
*/
|
|
26
|
-
_serialize(ctx) {
|
|
27
|
-
const o = {
|
|
28
|
-
name: this._name,
|
|
29
|
-
dataType: this._dataType,
|
|
30
|
-
isArray: this._isArray,
|
|
31
|
-
};
|
|
32
|
-
return ctx.serialize(this._type, o, () => this.__defaultSerialize(ctx, o));
|
|
33
|
-
}
|
|
34
|
-
__defaultSerialize(ctx, o) {
|
|
35
|
-
let prmValue = (ctx.params && ctx.params[o.name]) ?? null;
|
|
36
|
-
if (prmValue != null && o.isArray && !Array.isArray(prmValue))
|
|
37
|
-
prmValue = [prmValue];
|
|
38
|
-
ctx.preparedParams = ctx.preparedParams || {};
|
|
39
|
-
if (Array.isArray(ctx.preparedParams))
|
|
40
|
-
ctx.preparedParams.push(prmValue);
|
|
41
|
-
else
|
|
42
|
-
ctx.preparedParams[o.name] = prmValue;
|
|
43
|
-
const paramOps = {
|
|
44
|
-
dataType: this._dataType,
|
|
45
|
-
isArray: this._isArray,
|
|
46
|
-
};
|
|
47
|
-
ctx.paramOptions =
|
|
48
|
-
ctx.paramOptions || (Array.isArray(ctx.preparedParams) ? [] : {});
|
|
49
|
-
if (Array.isArray(ctx.paramOptions))
|
|
50
|
-
ctx.paramOptions.push(paramOps);
|
|
51
|
-
else
|
|
52
|
-
ctx.paramOptions[o.name] = paramOps;
|
|
53
|
-
return ':' + o.name;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.ParamExpression = ParamExpression;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RawStatement = void 0;
|
|
4
|
-
const enums_js_1 = require("../enums.js");
|
|
5
|
-
const serializable_js_1 = require("../serializable.js");
|
|
6
|
-
class RawStatement extends serializable_js_1.Serializable {
|
|
7
|
-
_text;
|
|
8
|
-
constructor(str) {
|
|
9
|
-
super();
|
|
10
|
-
this._text = str;
|
|
11
|
-
}
|
|
12
|
-
get _type() {
|
|
13
|
-
return enums_js_1.SerializationType.RAW;
|
|
14
|
-
}
|
|
15
|
-
_serialize(ctx) {
|
|
16
|
-
return ctx.serialize(this._type, this._text, () => this._text);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.RawStatement = RawStatement;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReturningColumn = void 0;
|
|
4
|
-
const enums_js_1 = require("../enums.js");
|
|
5
|
-
const base_field_js_1 = require("./base-field.js");
|
|
6
|
-
const RETURNING_COLUMN_PATTERN = /^([a-zA-Z_]\w*) *(?:as)? *(\w+)?$/;
|
|
7
|
-
class ReturningColumn extends base_field_js_1.BaseField {
|
|
8
|
-
_alias;
|
|
9
|
-
constructor(field) {
|
|
10
|
-
super();
|
|
11
|
-
const m = field.match(RETURNING_COLUMN_PATTERN);
|
|
12
|
-
if (!m)
|
|
13
|
-
throw new TypeError(`"${field}" does not match returning column format`);
|
|
14
|
-
this._field = m[1];
|
|
15
|
-
this._alias = m[2];
|
|
16
|
-
}
|
|
17
|
-
get _type() {
|
|
18
|
-
return enums_js_1.SerializationType.RETURNING_COLUMN;
|
|
19
|
-
}
|
|
20
|
-
_serialize(ctx) {
|
|
21
|
-
const o = {
|
|
22
|
-
field: this._field,
|
|
23
|
-
alias: this._alias,
|
|
24
|
-
};
|
|
25
|
-
ctx.returningFields = ctx.returningFields || [];
|
|
26
|
-
ctx.returningFields.push(o);
|
|
27
|
-
return ctx.serialize(this._type, o, () => ctx.escapeReserved(o.field) +
|
|
28
|
-
(o.alias ? ' as ' + ctx.escapeReserved(o.alias) : ''));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.ReturningColumn = ReturningColumn;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SequenceGetterStatement = void 0;
|
|
4
|
-
const enums_js_1 = require("../enums.js");
|
|
5
|
-
const serializable_js_1 = require("../serializable.js");
|
|
6
|
-
class SequenceGetterStatement extends serializable_js_1.Serializable {
|
|
7
|
-
_expression;
|
|
8
|
-
_next;
|
|
9
|
-
_alias;
|
|
10
|
-
constructor(expression, next) {
|
|
11
|
-
super();
|
|
12
|
-
this._expression = expression;
|
|
13
|
-
this._next = !!next;
|
|
14
|
-
}
|
|
15
|
-
get _type() {
|
|
16
|
-
return enums_js_1.SerializationType.SEQUENCE_GETTER_STATEMENT;
|
|
17
|
-
}
|
|
18
|
-
next(value) {
|
|
19
|
-
this._next = value;
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Sets alias to case expression.
|
|
24
|
-
*/
|
|
25
|
-
as(alias) {
|
|
26
|
-
this._alias = alias;
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Performs serialization
|
|
31
|
-
*
|
|
32
|
-
* @param {Object} ctx
|
|
33
|
-
* @return {string}
|
|
34
|
-
* @override
|
|
35
|
-
*/
|
|
36
|
-
_serialize(ctx) {
|
|
37
|
-
if (!this._expression)
|
|
38
|
-
return '';
|
|
39
|
-
const q = {
|
|
40
|
-
genName: this._expression,
|
|
41
|
-
next: this._next,
|
|
42
|
-
alias: this._alias,
|
|
43
|
-
};
|
|
44
|
-
return ctx.serialize(this._type, q, () => this.__defaultSerialize(ctx, q));
|
|
45
|
-
}
|
|
46
|
-
__defaultSerialize(ctx, o) {
|
|
47
|
-
return ((o.next ? 'nextval' : 'currval') +
|
|
48
|
-
"('" +
|
|
49
|
-
o.genName +
|
|
50
|
-
"')" +
|
|
51
|
-
(o.alias ? ' ' + o.alias : ''));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.SequenceGetterStatement = SequenceGetterStatement;
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StringAGGStatement = void 0;
|
|
4
|
-
const enums_js_1 = require("../enums.js");
|
|
5
|
-
const helpers_js_1 = require("../helpers.js");
|
|
6
|
-
const serializable_js_1 = require("../serializable.js");
|
|
7
|
-
const field_expression_js_1 = require("./field-expression.js");
|
|
8
|
-
const order_column_js_1 = require("./order-column.js");
|
|
9
|
-
class StringAGGStatement extends serializable_js_1.Serializable {
|
|
10
|
-
_field;
|
|
11
|
-
_delimiter;
|
|
12
|
-
_orderBy;
|
|
13
|
-
_alias;
|
|
14
|
-
constructor(field, delimiter) {
|
|
15
|
-
super();
|
|
16
|
-
this._field =
|
|
17
|
-
typeof field === 'string' ? new field_expression_js_1.FieldExpression(field) : field;
|
|
18
|
-
this._delimiter = delimiter || ',';
|
|
19
|
-
}
|
|
20
|
-
get _type() {
|
|
21
|
-
return enums_js_1.SerializationType.STRINGAGG_STATEMENT;
|
|
22
|
-
}
|
|
23
|
-
delimiter(value) {
|
|
24
|
-
this._delimiter = value;
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Defines "order by" part of StringAGG.
|
|
29
|
-
*/
|
|
30
|
-
orderBy(...field) {
|
|
31
|
-
this._orderBy = this._orderBy || [];
|
|
32
|
-
for (const arg of field) {
|
|
33
|
-
if (!arg)
|
|
34
|
-
continue;
|
|
35
|
-
this._orderBy.push(typeof arg === 'string' ? new order_column_js_1.OrderColumn(arg) : arg);
|
|
36
|
-
}
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Sets alias to case expression.
|
|
41
|
-
*/
|
|
42
|
-
as(alias) {
|
|
43
|
-
this._alias = alias;
|
|
44
|
-
return this;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Performs serialization
|
|
48
|
-
*
|
|
49
|
-
* @param {Object} ctx
|
|
50
|
-
* @return {string}
|
|
51
|
-
* @override
|
|
52
|
-
*/
|
|
53
|
-
_serialize(ctx) {
|
|
54
|
-
const q = {
|
|
55
|
-
field: ctx.anyToSQL(this._field),
|
|
56
|
-
delimiter: this._delimiter,
|
|
57
|
-
orderBy: this.__serializeOrderColumns(ctx),
|
|
58
|
-
alias: this._alias,
|
|
59
|
-
};
|
|
60
|
-
return ctx.serialize(this._type, q, () => this.__defaultSerialize(ctx, q));
|
|
61
|
-
}
|
|
62
|
-
__serializeOrderColumns(ctx) {
|
|
63
|
-
const arr = [];
|
|
64
|
-
if (this._orderBy) {
|
|
65
|
-
for (const t of this._orderBy) {
|
|
66
|
-
const s = t._serialize(ctx);
|
|
67
|
-
/* istanbul ignore else */
|
|
68
|
-
if (s)
|
|
69
|
-
arr.push(s);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return ctx.serialize(enums_js_1.SerializationType.SELECT_QUERY_ORDERBY, arr, () => {
|
|
73
|
-
const s = (0, helpers_js_1.printArray)(arr);
|
|
74
|
-
return s ? 'order by ' + s : '';
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
__defaultSerialize(ctx, o) {
|
|
78
|
-
return ('string_agg(' +
|
|
79
|
-
o.field +
|
|
80
|
-
",'" +
|
|
81
|
-
o.delimiter +
|
|
82
|
-
"'" +
|
|
83
|
-
(o.orderBy ? ' ' + o.orderBy : '') +
|
|
84
|
-
')' +
|
|
85
|
-
(o.alias ? ' ' + o.alias : ''));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.StringAGGStatement = StringAGGStatement;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TableName = void 0;
|
|
4
|
-
const enums_js_1 = require("../enums.js");
|
|
5
|
-
const serializable_js_1 = require("../serializable.js");
|
|
6
|
-
class TableName extends serializable_js_1.Serializable {
|
|
7
|
-
schema;
|
|
8
|
-
table;
|
|
9
|
-
alias;
|
|
10
|
-
constructor(tableName) {
|
|
11
|
-
super();
|
|
12
|
-
const m = tableName.match(/^(?:([a-zA-Z][\w$]*)\.)? *([a-zA-Z][\w$]*) *(?:as)? *(\w+)?$/);
|
|
13
|
-
if (!m)
|
|
14
|
-
throw new TypeError(`(${tableName}) does not match table name format`);
|
|
15
|
-
if (m[1])
|
|
16
|
-
this.schema = m[1];
|
|
17
|
-
if (m[2])
|
|
18
|
-
this.table = m[2];
|
|
19
|
-
if (m[3])
|
|
20
|
-
this.alias = m[3];
|
|
21
|
-
}
|
|
22
|
-
get _type() {
|
|
23
|
-
return enums_js_1.SerializationType.TABLE_NAME;
|
|
24
|
-
}
|
|
25
|
-
_serialize(ctx) {
|
|
26
|
-
return ctx.serialize(this._type, {
|
|
27
|
-
schema: this.schema,
|
|
28
|
-
table: this.table,
|
|
29
|
-
alias: this.alias,
|
|
30
|
-
}, () => (this.schema ? this.schema + '.' : '') +
|
|
31
|
-
this.table +
|
|
32
|
-
(this.alias ? ' ' + this.alias : ''));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.TableName = TableName;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UpperStatement = void 0;
|
|
4
|
-
const enums_js_1 = require("../enums.js");
|
|
5
|
-
const serializable_js_1 = require("../serializable.js");
|
|
6
|
-
class UpperStatement extends serializable_js_1.Serializable {
|
|
7
|
-
_expression;
|
|
8
|
-
_alias;
|
|
9
|
-
constructor(expression) {
|
|
10
|
-
super();
|
|
11
|
-
this._expression = expression;
|
|
12
|
-
}
|
|
13
|
-
get _type() {
|
|
14
|
-
return enums_js_1.SerializationType.UPPER_STATEMENT;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Sets alias to case expression.
|
|
18
|
-
*/
|
|
19
|
-
as(alias) {
|
|
20
|
-
this._alias = alias;
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Performs serialization
|
|
25
|
-
*
|
|
26
|
-
* @param {Object} ctx
|
|
27
|
-
* @return {string}
|
|
28
|
-
* @override
|
|
29
|
-
*/
|
|
30
|
-
_serialize(ctx) {
|
|
31
|
-
if (!this._expression)
|
|
32
|
-
return '';
|
|
33
|
-
const q = ctx.anyToSQL(this._expression);
|
|
34
|
-
return ctx.serialize(this._type, q, () => this.__defaultSerialize(ctx, q));
|
|
35
|
-
}
|
|
36
|
-
__defaultSerialize(ctx, o) {
|
|
37
|
-
return 'upper(' + o + ')' + (this._alias ? ' ' + this._alias : '');
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.UpperStatement = UpperStatement;
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Raw = Raw;
|
|
4
|
-
exports.Select = Select;
|
|
5
|
-
exports.Insert = Insert;
|
|
6
|
-
exports.Update = Update;
|
|
7
|
-
exports.Delete = Delete;
|
|
8
|
-
exports.Union = Union;
|
|
9
|
-
exports.UnionAll = UnionAll;
|
|
10
|
-
exports.Join = Join;
|
|
11
|
-
exports.InnerJoin = InnerJoin;
|
|
12
|
-
exports.LeftJoin = LeftJoin;
|
|
13
|
-
exports.LeftOuterJoin = LeftOuterJoin;
|
|
14
|
-
exports.RightJoin = RightJoin;
|
|
15
|
-
exports.RightOuterJoin = RightOuterJoin;
|
|
16
|
-
exports.OuterJoin = OuterJoin;
|
|
17
|
-
exports.FullOuterJoin = FullOuterJoin;
|
|
18
|
-
exports.CrossJoin = CrossJoin;
|
|
19
|
-
exports.Case = Case;
|
|
20
|
-
exports.Coalesce = Coalesce;
|
|
21
|
-
exports.Lower = Lower;
|
|
22
|
-
exports.Upper = Upper;
|
|
23
|
-
exports.Min = Min;
|
|
24
|
-
exports.Max = Max;
|
|
25
|
-
exports.StringAGG = StringAGG;
|
|
26
|
-
exports.Count = Count;
|
|
27
|
-
exports.SequenceNext = SequenceNext;
|
|
28
|
-
exports.SequenceCurr = SequenceCurr;
|
|
29
|
-
exports.Param = Param;
|
|
30
|
-
exports.Field = Field;
|
|
31
|
-
const enums_js_1 = require("./enums.js");
|
|
32
|
-
const delete_query_js_1 = require("./query/delete-query.js");
|
|
33
|
-
const insert_query_js_1 = require("./query/insert-query.js");
|
|
34
|
-
const select_query_js_1 = require("./query/select-query.js");
|
|
35
|
-
const union_query_js_1 = require("./query/union-query.js");
|
|
36
|
-
const update_query_js_1 = require("./query/update-query.js");
|
|
37
|
-
const case_statement_js_1 = require("./sql-objects/case-statement.js");
|
|
38
|
-
const coalesce_statement_js_1 = require("./sql-objects/coalesce-statement.js");
|
|
39
|
-
const count_statement_js_1 = require("./sql-objects/count-statement.js");
|
|
40
|
-
const field_expression_js_1 = require("./sql-objects/field-expression.js");
|
|
41
|
-
const join_statement_js_1 = require("./sql-objects/join-statement.js");
|
|
42
|
-
const lower_statement_js_1 = require("./sql-objects/lower-statement.js");
|
|
43
|
-
const max_statement_js_1 = require("./sql-objects/max-statement.js");
|
|
44
|
-
const min_statement_js_1 = require("./sql-objects/min-statement.js");
|
|
45
|
-
const param_expression_js_1 = require("./sql-objects/param-expression.js");
|
|
46
|
-
const raw_statement_js_1 = require("./sql-objects/raw-statement.js");
|
|
47
|
-
const sequence_getter_statement_js_1 = require("./sql-objects/sequence-getter-statement.js");
|
|
48
|
-
const string_agg_statement_js_1 = require("./sql-objects/string-agg-statement.js");
|
|
49
|
-
const upper_statement_js_1 = require("./sql-objects/upper-statement.js");
|
|
50
|
-
function Raw(text) {
|
|
51
|
-
return new raw_statement_js_1.RawStatement(text);
|
|
52
|
-
}
|
|
53
|
-
function Select(...column) {
|
|
54
|
-
return new select_query_js_1.SelectQuery(...column);
|
|
55
|
-
}
|
|
56
|
-
function Insert(tableName, input) {
|
|
57
|
-
return new insert_query_js_1.InsertQuery(tableName, input);
|
|
58
|
-
}
|
|
59
|
-
function Update(tableName, input) {
|
|
60
|
-
return new update_query_js_1.UpdateQuery(tableName, input);
|
|
61
|
-
}
|
|
62
|
-
function Delete(tableName) {
|
|
63
|
-
return new delete_query_js_1.DeleteQuery(tableName);
|
|
64
|
-
}
|
|
65
|
-
function Union(...queries) {
|
|
66
|
-
return new union_query_js_1.UnionQuery(queries);
|
|
67
|
-
}
|
|
68
|
-
function UnionAll(...queries) {
|
|
69
|
-
return new union_query_js_1.UnionQuery(queries, 'all');
|
|
70
|
-
}
|
|
71
|
-
function Join(table) {
|
|
72
|
-
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.INNER, table);
|
|
73
|
-
}
|
|
74
|
-
function InnerJoin(table) {
|
|
75
|
-
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.INNER, table);
|
|
76
|
-
}
|
|
77
|
-
function LeftJoin(table) {
|
|
78
|
-
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.LEFT, table);
|
|
79
|
-
}
|
|
80
|
-
function LeftOuterJoin(table) {
|
|
81
|
-
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.LEFT_OUTER, table);
|
|
82
|
-
}
|
|
83
|
-
function RightJoin(table) {
|
|
84
|
-
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.RIGHT, table);
|
|
85
|
-
}
|
|
86
|
-
function RightOuterJoin(table) {
|
|
87
|
-
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.RIGHT_OUTER, table);
|
|
88
|
-
}
|
|
89
|
-
function OuterJoin(table) {
|
|
90
|
-
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.OUTER, table);
|
|
91
|
-
}
|
|
92
|
-
function FullOuterJoin(table) {
|
|
93
|
-
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.FULL_OUTER, table);
|
|
94
|
-
}
|
|
95
|
-
function CrossJoin(table) {
|
|
96
|
-
return new join_statement_js_1.JoinStatement(enums_js_1.JoinType.CROSS, table);
|
|
97
|
-
}
|
|
98
|
-
function Case() {
|
|
99
|
-
return new case_statement_js_1.CaseStatement();
|
|
100
|
-
}
|
|
101
|
-
function Coalesce(...expressions) {
|
|
102
|
-
return new coalesce_statement_js_1.CoalesceStatement(...expressions);
|
|
103
|
-
}
|
|
104
|
-
function Lower(expression) {
|
|
105
|
-
return new lower_statement_js_1.LowerStatement(expression);
|
|
106
|
-
}
|
|
107
|
-
function Upper(expression) {
|
|
108
|
-
return new upper_statement_js_1.UpperStatement(expression);
|
|
109
|
-
}
|
|
110
|
-
function Min(expression) {
|
|
111
|
-
return new min_statement_js_1.MinStatement(expression);
|
|
112
|
-
}
|
|
113
|
-
function Max(expression) {
|
|
114
|
-
return new max_statement_js_1.MaxStatement(expression);
|
|
115
|
-
}
|
|
116
|
-
function StringAGG(field) {
|
|
117
|
-
return new string_agg_statement_js_1.StringAGGStatement(field);
|
|
118
|
-
}
|
|
119
|
-
function Count() {
|
|
120
|
-
return new count_statement_js_1.CountStatement();
|
|
121
|
-
}
|
|
122
|
-
function SequenceNext(expression) {
|
|
123
|
-
return new sequence_getter_statement_js_1.SequenceGetterStatement(expression, true);
|
|
124
|
-
}
|
|
125
|
-
function SequenceCurr(expression) {
|
|
126
|
-
return new sequence_getter_statement_js_1.SequenceGetterStatement(expression, false);
|
|
127
|
-
}
|
|
128
|
-
function Param(arg0, arg1, arg2) {
|
|
129
|
-
if (typeof arg0 === 'object')
|
|
130
|
-
return new param_expression_js_1.ParamExpression(arg0);
|
|
131
|
-
return new param_expression_js_1.ParamExpression({
|
|
132
|
-
name: arg0,
|
|
133
|
-
dataType: arg1,
|
|
134
|
-
isArray: arg2,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
function Field(arg0, arg1, arg2) {
|
|
138
|
-
if (typeof arg0 === 'object')
|
|
139
|
-
return new field_expression_js_1.FieldExpression(arg0);
|
|
140
|
-
return new field_expression_js_1.FieldExpression(arg0, arg1, arg2);
|
|
141
|
-
}
|
package/cjs/typeguards.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSerializable = isSerializable;
|
|
4
|
-
exports.isQuery = isQuery;
|
|
5
|
-
exports.isRawStatement = isRawStatement;
|
|
6
|
-
exports.isSelectQuery = isSelectQuery;
|
|
7
|
-
exports.isInsertQuery = isInsertQuery;
|
|
8
|
-
exports.isIUpdateQuery = isIUpdateQuery;
|
|
9
|
-
exports.isDeleteQuery = isDeleteQuery;
|
|
10
|
-
exports.isJoinStatement = isJoinStatement;
|
|
11
|
-
exports.isCaseStatement = isCaseStatement;
|
|
12
|
-
exports.isCountStatement = isCountStatement;
|
|
13
|
-
exports.isParamExpression = isParamExpression;
|
|
14
|
-
exports.isLogicalOperator = isLogicalOperator;
|
|
15
|
-
exports.isCompOperator = isCompOperator;
|
|
16
|
-
exports.isNotOperator = isNotOperator;
|
|
17
|
-
exports.isSelectColumn = isSelectColumn;
|
|
18
|
-
exports.isOrderColumn = isOrderColumn;
|
|
19
|
-
exports.isGroupColumn = isGroupColumn;
|
|
20
|
-
exports.isReturningColumn = isReturningColumn;
|
|
21
|
-
exports.isTableName = isTableName;
|
|
22
|
-
const enums_js_1 = require("./enums.js");
|
|
23
|
-
const query_js_1 = require("./query/query.js");
|
|
24
|
-
const serializable_js_1 = require("./serializable.js");
|
|
25
|
-
function isSerializable(value) {
|
|
26
|
-
return value instanceof serializable_js_1.Serializable;
|
|
27
|
-
}
|
|
28
|
-
function isQuery(value) {
|
|
29
|
-
return value instanceof query_js_1.Query;
|
|
30
|
-
}
|
|
31
|
-
function isRawStatement(value) {
|
|
32
|
-
return isSerializable(value) && value._type === enums_js_1.SerializationType.RAW;
|
|
33
|
-
}
|
|
34
|
-
function isSelectQuery(value) {
|
|
35
|
-
return (isSerializable(value) && value._type === enums_js_1.SerializationType.SELECT_QUERY);
|
|
36
|
-
}
|
|
37
|
-
function isInsertQuery(value) {
|
|
38
|
-
return (isSerializable(value) && value._type === enums_js_1.SerializationType.INSERT_QUERY);
|
|
39
|
-
}
|
|
40
|
-
function isIUpdateQuery(value) {
|
|
41
|
-
return (isSerializable(value) && value._type === enums_js_1.SerializationType.UPDATE_QUERY);
|
|
42
|
-
}
|
|
43
|
-
function isDeleteQuery(value) {
|
|
44
|
-
return (isSerializable(value) && value._type === enums_js_1.SerializationType.DELETE_QUERY);
|
|
45
|
-
}
|
|
46
|
-
function isJoinStatement(value) {
|
|
47
|
-
return isSerializable(value) && value._type === enums_js_1.SerializationType.JOIN;
|
|
48
|
-
}
|
|
49
|
-
function isCaseStatement(value) {
|
|
50
|
-
return (isSerializable(value) && value._type === enums_js_1.SerializationType.CASE_STATEMENT);
|
|
51
|
-
}
|
|
52
|
-
function isCountStatement(value) {
|
|
53
|
-
return (isSerializable(value) && value._type === enums_js_1.SerializationType.COUNT_STATEMENT);
|
|
54
|
-
}
|
|
55
|
-
function isParamExpression(value) {
|
|
56
|
-
return (isSerializable(value) &&
|
|
57
|
-
value._type === enums_js_1.SerializationType.EXTERNAL_PARAMETER);
|
|
58
|
-
}
|
|
59
|
-
function isLogicalOperator(value) {
|
|
60
|
-
return (isSerializable(value) &&
|
|
61
|
-
value._type === enums_js_1.SerializationType.LOGICAL_EXPRESSION);
|
|
62
|
-
}
|
|
63
|
-
function isCompOperator(value) {
|
|
64
|
-
return (isSerializable(value) &&
|
|
65
|
-
value._type === enums_js_1.SerializationType.COMPARISON_EXPRESSION);
|
|
66
|
-
}
|
|
67
|
-
function isNotOperator(value) {
|
|
68
|
-
return (isSerializable(value) &&
|
|
69
|
-
value._type === enums_js_1.SerializationType.NEGATIVE_EXPRESSION);
|
|
70
|
-
}
|
|
71
|
-
function isSelectColumn(value) {
|
|
72
|
-
return isSerializable(value) && value._type === enums_js_1.SerializationType.FIELD_NAME;
|
|
73
|
-
}
|
|
74
|
-
function isOrderColumn(value) {
|
|
75
|
-
return (isSerializable(value) && value._type === enums_js_1.SerializationType.ORDER_COLUMN);
|
|
76
|
-
}
|
|
77
|
-
function isGroupColumn(value) {
|
|
78
|
-
return (isSerializable(value) && value._type === enums_js_1.SerializationType.GROUP_COLUMN);
|
|
79
|
-
}
|
|
80
|
-
function isReturningColumn(value) {
|
|
81
|
-
return (isSerializable(value) && value._type === enums_js_1.SerializationType.RETURNING_COLUMN);
|
|
82
|
-
}
|
|
83
|
-
function isTableName(value) {
|
|
84
|
-
return isSerializable(value) && value._type === enums_js_1.SerializationType.TABLE_NAME;
|
|
85
|
-
}
|
package/cjs/types.js
DELETED
package/esm/package.json
DELETED
package/types/index.d.cts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export * as classes from './classes.ns.js';
|
|
2
|
-
export * from './enums.js';
|
|
3
|
-
export * from './extensions.js';
|
|
4
|
-
export * from './helpers.js';
|
|
5
|
-
export * from './op.initializers.js';
|
|
6
|
-
export { op } from './op.initializers.js';
|
|
7
|
-
export * from './query/delete-query.js';
|
|
8
|
-
export * from './query/insert-query.js';
|
|
9
|
-
export * from './query/query.js';
|
|
10
|
-
export * from './query/select-query.js';
|
|
11
|
-
export * from './query/update-query.js';
|
|
12
|
-
export * from './serializable.js';
|
|
13
|
-
export * from './serialize-context.js';
|
|
14
|
-
export * from './sql-objects/join-statement.js';
|
|
15
|
-
export * from './sql-objects/operator.js';
|
|
16
|
-
export * from './sql-objects/operators/comp-operator.js';
|
|
17
|
-
export * from './sql-objects/operators/logical-operator.js';
|
|
18
|
-
export * from './sqlobject.initializers.js';
|
|
19
|
-
export * from './typeguards.js';
|
|
20
|
-
export * from './types.js';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|