@sqb/builder 4.18.0 → 4.19.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.
|
@@ -29,7 +29,7 @@ class CompOperator extends operator_js_1.Operator {
|
|
|
29
29
|
const left = this.__serializeItem(ctx, this._left);
|
|
30
30
|
if (this._isArray)
|
|
31
31
|
left.isArray = true;
|
|
32
|
-
const right = this.__serializeItem(ctx, this._right,
|
|
32
|
+
const right = this.__serializeItem(ctx, this._right, left);
|
|
33
33
|
const o = {
|
|
34
34
|
operatorType: this._operatorType,
|
|
35
35
|
symbol: this._symbol,
|
|
@@ -38,13 +38,14 @@ class CompOperator extends operator_js_1.Operator {
|
|
|
38
38
|
};
|
|
39
39
|
return this.__serialize(ctx, o);
|
|
40
40
|
}
|
|
41
|
-
__serializeItem(ctx, x,
|
|
42
|
-
|
|
41
|
+
__serializeItem(ctx, x, left) {
|
|
42
|
+
const isRight = !!left;
|
|
43
|
+
if (ctx.strictParams && !(x instanceof serializable_js_1.Serializable) && isRight) {
|
|
43
44
|
ctx.strictParamGenId = ctx.strictParamGenId || 0;
|
|
44
45
|
const name = 'P$_' + ++ctx.strictParamGenId;
|
|
45
46
|
ctx.params = ctx.params || {};
|
|
46
47
|
ctx.params[name] = x;
|
|
47
|
-
x = (0, sqlobject_initializers_js_1.Param)(name);
|
|
48
|
+
x = (0, sqlobject_initializers_js_1.Param)(name, left?.dataType, left?.isArray || Array.isArray(x));
|
|
48
49
|
}
|
|
49
50
|
if (x instanceof serializable_js_1.Serializable) {
|
|
50
51
|
const expression = ctx.anyToSQL(x);
|
|
@@ -52,7 +53,7 @@ class CompOperator extends operator_js_1.Operator {
|
|
|
52
53
|
expression,
|
|
53
54
|
};
|
|
54
55
|
if (x instanceof field_expression_js_1.FieldExpression) {
|
|
55
|
-
result.dataType =
|
|
56
|
+
result.dataType = x._dataType;
|
|
56
57
|
result.isArray = x._isArray;
|
|
57
58
|
}
|
|
58
59
|
if (x instanceof param_expression_js_1.ParamExpression) {
|
|
@@ -65,9 +66,11 @@ class CompOperator extends operator_js_1.Operator {
|
|
|
65
66
|
}
|
|
66
67
|
return result;
|
|
67
68
|
}
|
|
69
|
+
// noinspection SuspiciousTypeOfGuard
|
|
68
70
|
const result = {
|
|
69
71
|
expression: isRight || typeof x !== 'string' ? ctx.anyToSQL(x) : x,
|
|
70
72
|
};
|
|
73
|
+
// noinspection SuspiciousTypeOfGuard
|
|
71
74
|
if (isRight || typeof x !== 'string')
|
|
72
75
|
result.isArray = Array.isArray(x);
|
|
73
76
|
return result;
|
|
@@ -26,7 +26,7 @@ export class CompOperator extends Operator {
|
|
|
26
26
|
const left = this.__serializeItem(ctx, this._left);
|
|
27
27
|
if (this._isArray)
|
|
28
28
|
left.isArray = true;
|
|
29
|
-
const right = this.__serializeItem(ctx, this._right,
|
|
29
|
+
const right = this.__serializeItem(ctx, this._right, left);
|
|
30
30
|
const o = {
|
|
31
31
|
operatorType: this._operatorType,
|
|
32
32
|
symbol: this._symbol,
|
|
@@ -35,13 +35,14 @@ export class CompOperator extends Operator {
|
|
|
35
35
|
};
|
|
36
36
|
return this.__serialize(ctx, o);
|
|
37
37
|
}
|
|
38
|
-
__serializeItem(ctx, x,
|
|
39
|
-
|
|
38
|
+
__serializeItem(ctx, x, left) {
|
|
39
|
+
const isRight = !!left;
|
|
40
|
+
if (ctx.strictParams && !(x instanceof Serializable) && isRight) {
|
|
40
41
|
ctx.strictParamGenId = ctx.strictParamGenId || 0;
|
|
41
42
|
const name = 'P$_' + ++ctx.strictParamGenId;
|
|
42
43
|
ctx.params = ctx.params || {};
|
|
43
44
|
ctx.params[name] = x;
|
|
44
|
-
x = Param(name);
|
|
45
|
+
x = Param(name, left?.dataType, left?.isArray || Array.isArray(x));
|
|
45
46
|
}
|
|
46
47
|
if (x instanceof Serializable) {
|
|
47
48
|
const expression = ctx.anyToSQL(x);
|
|
@@ -49,7 +50,7 @@ export class CompOperator extends Operator {
|
|
|
49
50
|
expression,
|
|
50
51
|
};
|
|
51
52
|
if (x instanceof FieldExpression) {
|
|
52
|
-
result.dataType =
|
|
53
|
+
result.dataType = x._dataType;
|
|
53
54
|
result.isArray = x._isArray;
|
|
54
55
|
}
|
|
55
56
|
if (x instanceof ParamExpression) {
|
|
@@ -62,9 +63,11 @@ export class CompOperator extends Operator {
|
|
|
62
63
|
}
|
|
63
64
|
return result;
|
|
64
65
|
}
|
|
66
|
+
// noinspection SuspiciousTypeOfGuard
|
|
65
67
|
const result = {
|
|
66
68
|
expression: isRight || typeof x !== 'string' ? ctx.anyToSQL(x) : x,
|
|
67
69
|
};
|
|
70
|
+
// noinspection SuspiciousTypeOfGuard
|
|
68
71
|
if (isRight || typeof x !== 'string')
|
|
69
72
|
result.isArray = Array.isArray(x);
|
|
70
73
|
return result;
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ export declare abstract class CompOperator extends Operator {
|
|
|
10
10
|
protected constructor(left: string | Serializable, right?: any);
|
|
11
11
|
get _type(): SerializationType;
|
|
12
12
|
_serialize(ctx: SerializeContext): string;
|
|
13
|
-
protected __serializeItem(ctx: SerializeContext, x:
|
|
13
|
+
protected __serializeItem(ctx: SerializeContext, x: string | Serializable, left?: any): any;
|
|
14
14
|
protected __serialize(ctx: SerializeContext, o: any): string;
|
|
15
15
|
protected __defaultSerialize(ctx: SerializeContext, o: any): string;
|
|
16
16
|
}
|