rado 0.4.8 → 0.4.9
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/dist/define/Expr.d.ts +3 -1
- package/dist/define/Expr.js +10 -0
- package/dist/lib/Formatter.js +17 -7
- package/package.json +1 -1
package/dist/define/Expr.d.ts
CHANGED
|
@@ -27,7 +27,8 @@ export declare enum BinOpType {
|
|
|
27
27
|
Match = "Match",
|
|
28
28
|
In = "In",
|
|
29
29
|
NotIn = "NotIn",
|
|
30
|
-
Concat = "Concat"
|
|
30
|
+
Concat = "Concat",
|
|
31
|
+
Collate = "Collate"
|
|
31
32
|
}
|
|
32
33
|
export declare enum ExprType {
|
|
33
34
|
UnOp = "ExprData.UnOp",
|
|
@@ -139,6 +140,7 @@ export declare class Expr<T> {
|
|
|
139
140
|
isLess(that: EV<any>): Expr<boolean>;
|
|
140
141
|
isLessOrEqual(that: EV<any>): Expr<boolean>;
|
|
141
142
|
add(this: Expr<number>, that: EV<number>, ...rest: Array<EV<number>>): Expr<number>;
|
|
143
|
+
collate(collation: string): Expr<string>;
|
|
142
144
|
subtract(this: Expr<number>, that: EV<number>, ...rest: Array<EV<number>>): Expr<number>;
|
|
143
145
|
multiply(this: Expr<number>, that: EV<number>, ...rest: Array<EV<number>>): Expr<number>;
|
|
144
146
|
remainder(this: Expr<number>, that: EV<number>): Expr<number>;
|
package/dist/define/Expr.js
CHANGED
|
@@ -28,6 +28,7 @@ var BinOpType = /* @__PURE__ */ ((BinOpType2) => {
|
|
|
28
28
|
BinOpType2["In"] = "In";
|
|
29
29
|
BinOpType2["NotIn"] = "NotIn";
|
|
30
30
|
BinOpType2["Concat"] = "Concat";
|
|
31
|
+
BinOpType2["Collate"] = "Collate";
|
|
31
32
|
return BinOpType2;
|
|
32
33
|
})(BinOpType || {});
|
|
33
34
|
var ExprType = /* @__PURE__ */ ((ExprType2) => {
|
|
@@ -284,6 +285,15 @@ class Expr {
|
|
|
284
285
|
)
|
|
285
286
|
);
|
|
286
287
|
}
|
|
288
|
+
collate(collation) {
|
|
289
|
+
return new Expr(
|
|
290
|
+
new ExprData.BinOp(
|
|
291
|
+
"Collate" /* Collate */,
|
|
292
|
+
this[Expr.Data],
|
|
293
|
+
ExprData.create(collation)
|
|
294
|
+
)
|
|
295
|
+
);
|
|
296
|
+
}
|
|
287
297
|
subtract(that, ...rest) {
|
|
288
298
|
return new Expr(
|
|
289
299
|
ExprData.createAll(this, that, ...rest).reduce(
|
package/dist/lib/Formatter.js
CHANGED
|
@@ -24,7 +24,8 @@ const binOps = {
|
|
|
24
24
|
[BinOpType.Match]: "MATCH",
|
|
25
25
|
[BinOpType.In]: "IN",
|
|
26
26
|
[BinOpType.NotIn]: "NOT IN",
|
|
27
|
-
[BinOpType.Concat]: "||"
|
|
27
|
+
[BinOpType.Concat]: "||",
|
|
28
|
+
[BinOpType.Collate]: "COLLATE"
|
|
28
29
|
};
|
|
29
30
|
const joins = {
|
|
30
31
|
left: "LEFT",
|
|
@@ -616,12 +617,21 @@ class Formatter {
|
|
|
616
617
|
const { stmt } = ctx;
|
|
617
618
|
stmt.openParenthesis();
|
|
618
619
|
this.formatExprValue(ctx, expr.a).add(binOps[expr.op]).space();
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
620
|
+
switch (expr.op) {
|
|
621
|
+
case BinOpType.Collate:
|
|
622
|
+
const value = expr.b.type === ExprType.Param && expr.b.param.type === ParamType.Value && expr.b.param.value;
|
|
623
|
+
if (typeof value !== "string")
|
|
624
|
+
throw new Error("Expected string");
|
|
625
|
+
stmt.add(this.escapeIdentifier(value));
|
|
626
|
+
return stmt.closeParenthesis();
|
|
627
|
+
case BinOpType.In:
|
|
628
|
+
case BinOpType.NotIn:
|
|
629
|
+
this.formatIn(ctx, expr.b);
|
|
630
|
+
return stmt.closeParenthesis();
|
|
631
|
+
default:
|
|
632
|
+
this.formatExprValue(ctx, expr.b);
|
|
633
|
+
return stmt.closeParenthesis();
|
|
634
|
+
}
|
|
625
635
|
}
|
|
626
636
|
formatParam(ctx, expr) {
|
|
627
637
|
const { stmt } = ctx;
|