rado 0.1.7 → 0.1.8
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/Column.d.ts +1 -1
- package/dist/Cursor.d.ts +1 -1
- package/dist/Cursor.js +3 -1
- package/dist/Expr.d.ts +3 -3
- package/dist/Functions.d.ts +0 -1
- package/dist/OrderBy.d.ts +1 -1
- package/dist/Param.d.ts +1 -1
- package/dist/Query.d.ts +1 -1
- package/dist/Statement.d.ts +1 -1
- package/dist/Target.d.ts +1 -1
- package/dist/sqlite/SqliteFormatter.d.ts +3 -1
- package/dist/sqlite/SqliteFormatter.js +18 -0
- package/dist/sqlite/SqliteFunctions.d.ts +3 -1
- package/package.json +1 -1
package/dist/Column.d.ts
CHANGED
package/dist/Cursor.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export declare namespace Cursor {
|
|
|
57
57
|
innerJoin<C>(that: Table<C>, ...on: Array<EV<boolean>>): SelectMultiple<T>;
|
|
58
58
|
select<X extends Selection>(selection: X): SelectMultiple<Selection.Infer<X>>;
|
|
59
59
|
count(): SelectSingle<number>;
|
|
60
|
-
orderBy(...orderBy: Array<OrderBy>): SelectMultiple<T>;
|
|
60
|
+
orderBy(...orderBy: Array<Expr<any> | OrderBy>): SelectMultiple<T>;
|
|
61
61
|
groupBy(...groupBy: Array<Expr<any>>): SelectMultiple<T>;
|
|
62
62
|
first(): SelectSingle<T | undefined>;
|
|
63
63
|
where(...where: Array<EV<boolean>>): SelectMultiple<T>;
|
package/dist/Cursor.js
CHANGED
package/dist/Expr.d.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { ParamData } from './Param';
|
|
|
5
5
|
import { Query } from './Query';
|
|
6
6
|
import { Selection } from './Selection';
|
|
7
7
|
import { Target } from './Target';
|
|
8
|
-
export declare
|
|
8
|
+
export declare enum UnOp {
|
|
9
9
|
Not = "Not",
|
|
10
10
|
IsNull = "IsNull"
|
|
11
11
|
}
|
|
12
|
-
export declare
|
|
12
|
+
export declare enum BinOp {
|
|
13
13
|
Add = "Add",
|
|
14
14
|
Subt = "Subt",
|
|
15
15
|
Mult = "Mult",
|
|
@@ -30,7 +30,7 @@ export declare const enum BinOp {
|
|
|
30
30
|
NotIn = "NotIn",
|
|
31
31
|
Concat = "Concat"
|
|
32
32
|
}
|
|
33
|
-
export declare
|
|
33
|
+
export declare enum ExprType {
|
|
34
34
|
UnOp = "UnOp",
|
|
35
35
|
BinOp = "BinOp",
|
|
36
36
|
Field = "Field",
|
package/dist/Functions.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { EV, Expr } from './Expr';
|
|
|
2
2
|
export declare const Functions: Functions;
|
|
3
3
|
/** These will have to be supported in every driver */
|
|
4
4
|
export type Functions = {
|
|
5
|
-
arrayLength(x: EV<Array<any>>): Expr<number>;
|
|
6
5
|
count(x?: Expr<any>): Expr<number>;
|
|
7
6
|
iif<T>(x: EV<boolean>, y: EV<T>, z: EV<T>): Expr<T>;
|
|
8
7
|
};
|
package/dist/OrderBy.d.ts
CHANGED
package/dist/Param.d.ts
CHANGED
package/dist/Query.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ExprData } from './Expr';
|
|
|
3
3
|
import { OrderBy } from './OrderBy';
|
|
4
4
|
import { Index, Schema } from './Schema';
|
|
5
5
|
import { Target } from './Target';
|
|
6
|
-
export declare
|
|
6
|
+
export declare enum QueryType {
|
|
7
7
|
Insert = "Insert",
|
|
8
8
|
Select = "Select",
|
|
9
9
|
Update = "Update",
|
package/dist/Statement.d.ts
CHANGED
package/dist/Target.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExprData } from '../Expr';
|
|
2
|
+
import { FormatContext, Formatter } from '../Formatter';
|
|
2
3
|
import { Statement } from '../Statement';
|
|
3
4
|
export declare class SqliteFormatter extends Formatter {
|
|
4
5
|
escapeValue(value: any): string;
|
|
@@ -6,4 +7,5 @@ export declare class SqliteFormatter extends Formatter {
|
|
|
6
7
|
escapeString(input: string): string;
|
|
7
8
|
formatSqlAccess(on: Statement, field: string): Statement;
|
|
8
9
|
formatJsonAccess(on: Statement, field: string): Statement;
|
|
10
|
+
formatExpr(expr: ExprData, ctx: FormatContext): Statement;
|
|
9
11
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// src/sqlite/SqliteFormatter.ts
|
|
2
|
+
import { ExprType } from "../Expr.js";
|
|
2
3
|
import { Formatter } from "../Formatter.js";
|
|
4
|
+
import { identifier } from "../Statement.js";
|
|
5
|
+
import { TargetType } from "../Target.js";
|
|
3
6
|
function escapeWithin(input, outer) {
|
|
4
7
|
let buf = outer;
|
|
5
8
|
for (const char of input) {
|
|
@@ -37,6 +40,21 @@ var SqliteFormatter = class extends Formatter {
|
|
|
37
40
|
const target = this.formatString(`$.${field}`);
|
|
38
41
|
return on.raw("->").concat(target);
|
|
39
42
|
}
|
|
43
|
+
formatExpr(expr, ctx) {
|
|
44
|
+
switch (expr.type) {
|
|
45
|
+
case ExprType.Call:
|
|
46
|
+
if (expr.method === "match") {
|
|
47
|
+
const [from, query] = expr.params;
|
|
48
|
+
if (from.type !== ExprType.Row)
|
|
49
|
+
throw new Error("not implemented");
|
|
50
|
+
if (from.target.type !== TargetType.Table)
|
|
51
|
+
throw new Error("not implemented");
|
|
52
|
+
return identifier(from.target.table.alias || from.target.table.name).raw(" match ").concat(this.formatExprValue(query, ctx));
|
|
53
|
+
}
|
|
54
|
+
default:
|
|
55
|
+
return super.formatExpr(expr, ctx);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
40
58
|
};
|
|
41
59
|
export {
|
|
42
60
|
SqliteFormatter
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { EV, Expr } from '../Expr';
|
|
2
|
+
import { Table } from '../Table';
|
|
2
3
|
export declare const SqliteFunctions: SqliteFunctions;
|
|
3
4
|
export type SqliteFunctions = {
|
|
4
|
-
|
|
5
|
+
/** Use the match operator for the FTS5 module */
|
|
6
|
+
match(table: Table<any>, searchTerm: EV<string>): Expr<boolean>;
|
|
5
7
|
cast(x: EV<any>, type: 'text'): Expr<string>;
|
|
6
8
|
cast(x: EV<any>, type: 'real'): Expr<number>;
|
|
7
9
|
cast(x: EV<any>, type: 'integer'): Expr<number>;
|