rado 0.1.29 → 0.1.31
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/index.d.ts +1 -1
- package/dist/index.js +4 -1
- package/dist/lib/Formatter.d.ts +35 -36
- package/dist/lib/Formatter.js +388 -280
- package/dist/lib/Functions.d.ts +2 -4
- package/dist/lib/Schema.js +6 -1
- package/dist/lib/Statement.d.ts +19 -32
- package/dist/lib/Statement.js +36 -89
- package/dist/sqlite/SqliteFormatter.d.ts +2 -3
- package/dist/sqlite/SqliteFormatter.js +11 -11
- package/dist/sqlite/SqliteFunctions.d.ts +11 -6
- package/dist/sqlite/SqliteFunctions.js +4 -2
- package/dist/sqlite/SqliteSchema.js +11 -8
- package/package.json +1 -1
package/dist/lib/Functions.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Expr } from './Expr';
|
|
2
2
|
export declare const Functions: Functions;
|
|
3
|
-
/** These will have to be supported in every driver */
|
|
4
3
|
export type Functions = {
|
|
5
|
-
|
|
6
|
-
iif<T>(x: EV<boolean>, y: EV<T>, z: EV<T>): Expr<T>;
|
|
4
|
+
[key: string]: (...args: Array<any>) => Expr<any>;
|
|
7
5
|
};
|
package/dist/lib/Schema.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/lib/Schema.ts
|
|
2
2
|
import { Query } from "./Query.js";
|
|
3
|
+
import { Statement } from "./Statement.js";
|
|
3
4
|
var Schema;
|
|
4
5
|
((Schema2) => {
|
|
5
6
|
function create(schema) {
|
|
@@ -27,7 +28,10 @@ var Schema;
|
|
|
27
28
|
} else if (!schemaCol) {
|
|
28
29
|
res.push(Query.AlterTable({ table: schema, dropColumn: columnName }));
|
|
29
30
|
} else {
|
|
30
|
-
const { sql: instruction } = formatter.formatColumn(
|
|
31
|
+
const { sql: instruction } = formatter.formatColumn(
|
|
32
|
+
{ stmt: new Statement() },
|
|
33
|
+
{ ...schemaCol, references: void 0 }
|
|
34
|
+
).compile(formatter);
|
|
31
35
|
if (removeLeadingWhitespace(localInstruction) !== removeLeadingWhitespace(instruction)) {
|
|
32
36
|
res.push(Query.AlterTable({ table: schema, alterColumn: schemaCol }));
|
|
33
37
|
}
|
|
@@ -46,6 +50,7 @@ var Schema;
|
|
|
46
50
|
res.unshift(Query.DropIndex({ table: schema, name: indexName }));
|
|
47
51
|
} else {
|
|
48
52
|
const { sql: instruction } = formatter.formatCreateIndex(
|
|
53
|
+
{ stmt: new Statement() },
|
|
49
54
|
Query.CreateIndex({ table: schema, index: schemaIndex })
|
|
50
55
|
).compile(formatter);
|
|
51
56
|
if (removeLeadingWhitespace(localInstruction) !== removeLeadingWhitespace(instruction)) {
|
package/dist/lib/Statement.d.ts
CHANGED
|
@@ -25,30 +25,26 @@ export interface CompileOptions {
|
|
|
25
25
|
}
|
|
26
26
|
export declare class Statement {
|
|
27
27
|
tokens: Array<Token>;
|
|
28
|
-
constructor(tokens
|
|
29
|
-
concat(...tokens: Array<Token
|
|
30
|
-
static create(from: string | Statement): Statement;
|
|
28
|
+
constructor(tokens?: Array<Token>);
|
|
29
|
+
concat(...tokens: Array<Token>): this;
|
|
31
30
|
static tag(strings: ReadonlyArray<string>, params: Array<Statement>): Statement;
|
|
32
|
-
space():
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
addParenthesis(stmnt: string | Statement): Statement;
|
|
50
|
-
separated(input: Array<Statement>, separator?: string): Statement;
|
|
51
|
-
addSeparated(input: Array<Statement>, separator?: string): Statement;
|
|
31
|
+
space(): this;
|
|
32
|
+
add(addition: undefined | string): this;
|
|
33
|
+
addLine(addition: undefined | string): this;
|
|
34
|
+
indent(): this;
|
|
35
|
+
dedent(): this;
|
|
36
|
+
newline(ignore?: boolean): this;
|
|
37
|
+
identifier(name: string): this;
|
|
38
|
+
addIdentifier(name: string): this;
|
|
39
|
+
value(value: any): this;
|
|
40
|
+
addValue(value: any): this;
|
|
41
|
+
param(name: string): this;
|
|
42
|
+
addParam(name: string): this;
|
|
43
|
+
raw(query: string): this;
|
|
44
|
+
openParenthesis(): this;
|
|
45
|
+
closeParenthesis(): this;
|
|
46
|
+
call<T>(parts: Array<T>, separator?: string): Generator<T, void, unknown>;
|
|
47
|
+
separate<T>(parts: Array<T>, separator?: string): Generator<T, void, unknown>;
|
|
52
48
|
isEmpty(): boolean;
|
|
53
49
|
compile(sanitizer: Sanitizer, formatInline?: boolean): CompiledStatement;
|
|
54
50
|
}
|
|
@@ -60,13 +56,4 @@ export declare class CompiledStatement {
|
|
|
60
56
|
params(input?: Record<string, any>): Array<any>;
|
|
61
57
|
toString(): string;
|
|
62
58
|
}
|
|
63
|
-
export declare function newline(): Statement;
|
|
64
|
-
export declare function raw(raw: string): Statement;
|
|
65
|
-
export declare function identifier(name: string): Statement;
|
|
66
|
-
export declare function value(value: any): Statement;
|
|
67
|
-
export declare function param(name: string): Statement;
|
|
68
|
-
export declare function empty(): Statement;
|
|
69
|
-
export declare function parenthesis(stmnt: Statement): Statement;
|
|
70
|
-
export declare function call(method: string, ...args: Array<Statement>): Statement;
|
|
71
|
-
export declare function separated(input: Array<Statement>, separator?: string): Statement;
|
|
72
59
|
export {};
|
package/dist/lib/Statement.js
CHANGED
|
@@ -24,58 +24,39 @@ var Token = class {
|
|
|
24
24
|
return new Token("Param" /* Param */, name);
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
var SEPARATE = ",";
|
|
27
|
+
var SEPARATE = ", ";
|
|
28
28
|
var WHITESPACE = " ";
|
|
29
29
|
var NEWLINE = "\n";
|
|
30
30
|
var Statement = class {
|
|
31
|
-
constructor(tokens) {
|
|
31
|
+
constructor(tokens = []) {
|
|
32
32
|
this.tokens = tokens;
|
|
33
33
|
}
|
|
34
34
|
concat(...tokens) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
...tokens.flatMap((t) => t instanceof Statement ? t.tokens : [t])
|
|
38
|
-
)
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
static create(from) {
|
|
42
|
-
return typeof from === "string" ? raw(from) : from;
|
|
35
|
+
this.tokens.push(...tokens);
|
|
36
|
+
return this;
|
|
43
37
|
}
|
|
44
38
|
static tag(strings, params) {
|
|
45
39
|
return new Statement(
|
|
46
40
|
strings.flatMap((s, i) => {
|
|
47
|
-
const
|
|
48
|
-
return [Token.Raw(s)].concat(
|
|
41
|
+
const param = params[i];
|
|
42
|
+
return [Token.Raw(s)].concat(param ? param.tokens : []);
|
|
49
43
|
})
|
|
50
44
|
);
|
|
51
45
|
}
|
|
52
46
|
space() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return this.identifier(method).parenthesis(separated(args));
|
|
57
|
-
}
|
|
58
|
-
addCall(method, ...args) {
|
|
59
|
-
return this.space().call(method, ...args);
|
|
47
|
+
if (this.tokens.length === 0)
|
|
48
|
+
return this;
|
|
49
|
+
return this.raw(WHITESPACE);
|
|
60
50
|
}
|
|
61
51
|
add(addition) {
|
|
62
52
|
if (!addition)
|
|
63
53
|
return this;
|
|
64
|
-
|
|
65
|
-
return this;
|
|
66
|
-
return this.space().concat(Statement.create(addition));
|
|
54
|
+
return this.space().raw(addition);
|
|
67
55
|
}
|
|
68
56
|
addLine(addition) {
|
|
69
57
|
if (!addition)
|
|
70
58
|
return this;
|
|
71
|
-
|
|
72
|
-
return this;
|
|
73
|
-
return this.newline().concat(Statement.create(addition));
|
|
74
|
-
}
|
|
75
|
-
addIf(condition, addition) {
|
|
76
|
-
if (!condition)
|
|
77
|
-
return this;
|
|
78
|
-
return this.add(typeof addition === "function" ? addition() : addition);
|
|
59
|
+
return this.newline().add(addition);
|
|
79
60
|
}
|
|
80
61
|
indent() {
|
|
81
62
|
return this.concat(Token.Indent());
|
|
@@ -94,11 +75,11 @@ var Statement = class {
|
|
|
94
75
|
addIdentifier(name) {
|
|
95
76
|
return this.space().identifier(name);
|
|
96
77
|
}
|
|
97
|
-
value(
|
|
98
|
-
return this.concat(Token.Value(
|
|
78
|
+
value(value) {
|
|
79
|
+
return this.concat(Token.Value(value));
|
|
99
80
|
}
|
|
100
|
-
addValue(
|
|
101
|
-
return this.space().value(
|
|
81
|
+
addValue(value) {
|
|
82
|
+
return this.space().value(value);
|
|
102
83
|
}
|
|
103
84
|
param(name) {
|
|
104
85
|
return this.concat(Token.Param(name));
|
|
@@ -111,21 +92,23 @@ var Statement = class {
|
|
|
111
92
|
return this;
|
|
112
93
|
return this.concat(Token.Raw(query));
|
|
113
94
|
}
|
|
114
|
-
|
|
115
|
-
return this.raw("(").indent().newline()
|
|
95
|
+
openParenthesis() {
|
|
96
|
+
return this.raw("(").indent().newline();
|
|
116
97
|
}
|
|
117
|
-
|
|
118
|
-
return this.
|
|
98
|
+
closeParenthesis() {
|
|
99
|
+
return this.dedent().newline().raw(")");
|
|
119
100
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
)
|
|
125
|
-
);
|
|
101
|
+
*call(parts, separator = SEPARATE) {
|
|
102
|
+
this.openParenthesis();
|
|
103
|
+
yield* this.separate(parts, separator);
|
|
104
|
+
this.closeParenthesis();
|
|
126
105
|
}
|
|
127
|
-
|
|
128
|
-
|
|
106
|
+
*separate(parts, separator = SEPARATE) {
|
|
107
|
+
for (let i = 0; i < parts.length; i++) {
|
|
108
|
+
if (i > 0)
|
|
109
|
+
this.raw(separator).newline();
|
|
110
|
+
yield parts[i];
|
|
111
|
+
}
|
|
129
112
|
}
|
|
130
113
|
isEmpty() {
|
|
131
114
|
return this.tokens.length === 0 || this.tokens.length === 1 && this.tokens[0].type === "Raw" /* Raw */ && this.tokens[0].data === "";
|
|
@@ -173,56 +156,20 @@ var CompiledStatement = class {
|
|
|
173
156
|
this.paramData = paramData;
|
|
174
157
|
}
|
|
175
158
|
params(input) {
|
|
176
|
-
return this.paramData.map((
|
|
177
|
-
if (
|
|
178
|
-
if (input &&
|
|
179
|
-
return this.sanitizer.formatParamValue(input[
|
|
180
|
-
throw new TypeError(`Missing parameter ${
|
|
159
|
+
return this.paramData.map((param) => {
|
|
160
|
+
if (param.type === ParamType.Named) {
|
|
161
|
+
if (input && param.name in input)
|
|
162
|
+
return this.sanitizer.formatParamValue(input[param.name]);
|
|
163
|
+
throw new TypeError(`Missing parameter ${param.name}`);
|
|
181
164
|
}
|
|
182
|
-
return this.sanitizer.formatParamValue(
|
|
165
|
+
return this.sanitizer.formatParamValue(param.value);
|
|
183
166
|
});
|
|
184
167
|
}
|
|
185
168
|
toString() {
|
|
186
169
|
return this.sql;
|
|
187
170
|
}
|
|
188
171
|
};
|
|
189
|
-
function newline() {
|
|
190
|
-
return new Statement([Token.Raw(NEWLINE)]);
|
|
191
|
-
}
|
|
192
|
-
function raw(raw2) {
|
|
193
|
-
return new Statement([Token.Raw(raw2)]);
|
|
194
|
-
}
|
|
195
|
-
function identifier(name) {
|
|
196
|
-
return new Statement([Token.Identifier(name)]);
|
|
197
|
-
}
|
|
198
|
-
function value(value2) {
|
|
199
|
-
return new Statement([Token.Value(value2)]);
|
|
200
|
-
}
|
|
201
|
-
function param(name) {
|
|
202
|
-
return new Statement([Token.Param(name)]);
|
|
203
|
-
}
|
|
204
|
-
function empty() {
|
|
205
|
-
return new Statement([]);
|
|
206
|
-
}
|
|
207
|
-
function parenthesis(stmnt) {
|
|
208
|
-
return empty().parenthesis(stmnt);
|
|
209
|
-
}
|
|
210
|
-
function call(method, ...args) {
|
|
211
|
-
return identifier(method).parenthesis(separated(args));
|
|
212
|
-
}
|
|
213
|
-
function separated(input, separator = SEPARATE) {
|
|
214
|
-
return empty().separated(input, separator);
|
|
215
|
-
}
|
|
216
172
|
export {
|
|
217
173
|
CompiledStatement,
|
|
218
|
-
Statement
|
|
219
|
-
call,
|
|
220
|
-
empty,
|
|
221
|
-
identifier,
|
|
222
|
-
newline,
|
|
223
|
-
param,
|
|
224
|
-
parenthesis,
|
|
225
|
-
raw,
|
|
226
|
-
separated,
|
|
227
|
-
value
|
|
174
|
+
Statement
|
|
228
175
|
};
|
|
@@ -6,7 +6,6 @@ export declare class SqliteFormatter extends Formatter {
|
|
|
6
6
|
escapeValue(value: any): string;
|
|
7
7
|
escapeIdentifier(input: string): string;
|
|
8
8
|
escapeString(input: string): string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
formatExpr(expr: ExprData, ctx: FormatContext): Statement;
|
|
9
|
+
formatAccess(ctx: FormatContext, mkSubject: () => void, field: string): Statement;
|
|
10
|
+
formatExpr(ctx: FormatContext, expr: ExprData): Statement;
|
|
12
11
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// src/sqlite/SqliteFormatter.ts
|
|
2
2
|
import { ExprType } from "../lib/Expr.js";
|
|
3
3
|
import { Formatter } from "../lib/Formatter.js";
|
|
4
|
-
import { identifier } from "../lib/Statement.js";
|
|
5
4
|
import { TargetType } from "../lib/Target.js";
|
|
6
5
|
function escapeWithin(input, outer) {
|
|
7
6
|
let buf = outer;
|
|
@@ -43,15 +42,14 @@ var SqliteFormatter = class extends Formatter {
|
|
|
43
42
|
escapeString(input) {
|
|
44
43
|
return escapeWithin(input, "'");
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
45
|
+
formatAccess(ctx, mkSubject, field) {
|
|
46
|
+
const { stmt, formatAsJson } = ctx;
|
|
47
|
+
mkSubject();
|
|
48
|
+
stmt.raw(formatAsJson ? "->" : "->>");
|
|
49
|
+
return this.formatString(ctx, `$.${field}`);
|
|
49
50
|
}
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
return on.raw("->").concat(target);
|
|
53
|
-
}
|
|
54
|
-
formatExpr(expr, ctx) {
|
|
51
|
+
formatExpr(ctx, expr) {
|
|
52
|
+
const { stmt } = ctx;
|
|
55
53
|
switch (expr.type) {
|
|
56
54
|
case ExprType.Call:
|
|
57
55
|
if (expr.method === "match") {
|
|
@@ -60,10 +58,12 @@ var SqliteFormatter = class extends Formatter {
|
|
|
60
58
|
throw new Error("not implemented");
|
|
61
59
|
if (from.target.type !== TargetType.Table)
|
|
62
60
|
throw new Error("not implemented");
|
|
63
|
-
|
|
61
|
+
stmt.identifier(from.target.table.alias || from.target.table.name).raw(" MATCH ");
|
|
62
|
+
this.formatExprValue(ctx, query);
|
|
63
|
+
return stmt;
|
|
64
64
|
}
|
|
65
65
|
default:
|
|
66
|
-
return super.formatExpr(
|
|
66
|
+
return super.formatExpr(ctx, expr);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
};
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
+
import { Cursor } from '../lib/Cursor';
|
|
1
2
|
import { EV, Expr } from '../lib/Expr';
|
|
2
3
|
import { Table } from '../lib/Table';
|
|
3
4
|
export declare const SqliteFunctions: SqliteFunctions;
|
|
4
5
|
export type SqliteFunctions = {
|
|
6
|
+
/** The count(X) function returns a count of the number of times that X is not NULL in a group. The count(*) function (with no arguments) returns the total number of rows in the group. */
|
|
7
|
+
count(x?: Expr<any>): Expr<number>;
|
|
8
|
+
/** The iif(X,Y,Z) function returns the value Y if X is true, and Z otherwise. The iif(X,Y,Z) function is logically equivalent to and generates the same bytecode as the CASE Expr "CASE WHEN X THEN Y ELSE Z END".*/
|
|
9
|
+
iif<T>(x: EV<boolean>, y: EV<T>, z: EV<T>): Expr<T>;
|
|
10
|
+
/**
|
|
11
|
+
* The EXISTS operator always evaluates to one of the integer values 0 and 1. If executing the SELECT statement specified as the right-hand operand of the EXISTS operator would return one or more rows, then the EXISTS operator evaluates to 1. If executing the SELECT would return no rows at all, then the EXISTS operator evaluates to 0.
|
|
12
|
+
*/
|
|
13
|
+
exists(cursor: Cursor<any>): Expr<boolean>;
|
|
5
14
|
/** Use the match operator for the FTS5 module */
|
|
6
15
|
match(table: Table<any>, searchTerm: EV<string>): Expr<boolean>;
|
|
7
16
|
cast(x: EV<any>, type: 'text'): Expr<string>;
|
|
@@ -19,8 +28,6 @@ export type SqliteFunctions = {
|
|
|
19
28
|
/** The hex() function numbererprets its argument as a BLOB and returns a string which is the upper-case hexadecimal rendering of the content of that blob. If the argument X in "hex(X)" is an numbereger or numbering ponumber number, then "numbererprets its argument as a BLOB" means that the binary number is first converted numbero a UTF8 text representation, then that text is numbererpreted as a BLOB. Hence, "hex(12345678)" renders as "3132333435363738" not the binary representation of the numbereger value "0000000000BC614E".*/
|
|
20
29
|
/** The ifnull() function returns a copy of its first non-NULL argument, or NULL if both arguments are NULL. Ifnull() must have exactly 2 arguments. The ifnull() function is equivalent to coalesce() with two arguments.*/
|
|
21
30
|
ifnull<T>(x: EV<T>, y: EV<T>): Expr<T>;
|
|
22
|
-
/** The iif(X,Y,Z) function returns the value Y if X is true, and Z otherwise. The iif(X,Y,Z) function is logically equivalent to and generates the same bytecode as the CASE Expr "CASE WHEN X THEN Y ELSE Z END".*/
|
|
23
|
-
iif<T>(x: EV<boolean>, y: EV<T>, z: EV<T>): Expr<T>;
|
|
24
31
|
/** The instr(X,Y) function finds the first occurrence of string Y within string X and returns the number of prior characters plus 1, or 0 if Y is nowhere found within X. Or, if X and Y are both BLOBs, then instr(X,Y) returns one more than the number bytes prior to the first occurrence of Y, or 0 if Y does not occur anywhere within X. If both arguments X and Y to instr(X,Y) are non-NULL and are not BLOBs then both are numbererpreted as strings. If either X or Y are NULL in instr(X,Y) then the result is NULL.*/
|
|
25
32
|
instr(x: EV<string>, y: EV<string>): Expr<number>;
|
|
26
33
|
/** The last_insert_rowid() function returns the ROWID of the last row insert from the database connection which invoked the function. The last_insert_rowid() SQL function is a wrapper around the sqlite3_last_insert_rowid() C/C++ numbererface function.*/
|
|
@@ -76,8 +83,6 @@ export type SqliteFunctions = {
|
|
|
76
83
|
upper(x: EV<string>): Expr<string>;
|
|
77
84
|
/** The avg() function returns the average value of all non-NULL X within a group. string and BLOB values that do not look like numbers are numbererpreted as 0. The result of avg() is always a numbering ponumber value as long as at there is at least one non-NULL input even if all inputs are numberegers. The result of avg() is NULL if and only if there are no non-NULL inputs. */
|
|
78
85
|
avg(x: Expr<number>): Expr<number>;
|
|
79
|
-
/** The count(X) function returns a count of the number of times that X is not NULL in a group. The count(*) function (with no arguments) returns the total number of rows in the group. */
|
|
80
|
-
count(x?: Expr<any>): Expr<number>;
|
|
81
86
|
/** The group_concat() function returns a string which is the concatenation of all non-NULL values of X. If parameter Y is present then it is used as the separator between instances of X. A comma (",") is used as the separator if Y is omitted. The order of the concatenated elements is arbitrary. */
|
|
82
87
|
group_concat(x: EV<string>, y: EV<string>): Expr<string>;
|
|
83
88
|
/** The sum() and total() aggregate functions return sum of all non-NULL values in the group. If there are no non-NULL input rows then sum() returns NULL but total() returns 0.0. NULL is not normally a helpful result for the sum of no rows but the SQL standard requires it and most other SQL database engines implement sum() that way so SQLite does it in the same way in order to be compatible. The non-standard total() function is provided as a convenient way to work around this design problem in the SQL language.
|
|
@@ -148,9 +153,9 @@ export type SqliteFunctions = {
|
|
|
148
153
|
julianday(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
|
|
149
154
|
strftime(format: EV<string>, timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
|
|
150
155
|
};
|
|
151
|
-
export declare const match: (table: Table<any>, searchTerm: EV<string>) => Expr<boolean>, cast: {
|
|
156
|
+
export declare const count: (x?: Expr<any>) => Expr<number>, iif: <T>(x: EV<boolean>, y: EV<T>, z: EV<T>) => Expr<T>, exists: (cursor: Cursor<any>) => Expr<boolean>, match: (table: Table<any>, searchTerm: EV<string>) => Expr<boolean>, cast: {
|
|
152
157
|
(x: EV<any>, type: 'text'): Expr<string>;
|
|
153
158
|
(x: EV<any>, type: 'real'): Expr<number>;
|
|
154
159
|
(x: EV<any>, type: 'integer'): Expr<number>;
|
|
155
160
|
(x: EV<any>, type: 'numeric'): Expr<number>;
|
|
156
|
-
}, abs: (x: EV<number>) => Expr<number>, changes: () => Expr<number>, char: (...arg: Array<EV<number>>) => Expr<string>, coalesce: (x: EV<any>, y: EV<any>, ...rest: EV<any>) => Expr<any>, ifnull: <T>(x: EV<T>, y: EV<T>) => Expr<T>,
|
|
161
|
+
}, abs: (x: EV<number>) => Expr<number>, changes: () => Expr<number>, char: (...arg: Array<EV<number>>) => Expr<string>, coalesce: (x: EV<any>, y: EV<any>, ...rest: EV<any>) => Expr<any>, ifnull: <T>(x: EV<T>, y: EV<T>) => Expr<T>, instr: (x: EV<string>, y: EV<string>) => Expr<number>, last_insert_rowid: () => Expr<number>, length: (x: EV<string>) => Expr<number>, likelihood: (x: EV<boolean>, y: number) => Expr<boolean>, likely: (x: EV<boolean>) => Expr<boolean>, lower: (x: EV<string>) => Expr<string>, ltrim: (x: EV<string>, y?: EV<string>) => Expr<string>, max: <T>(x: EV<T>, y: EV<T>, ...rest: EV<T>[]) => Expr<T>, min: <T>(x: EV<T>, y: EV<T>, ...rest: EV<T>[]) => Expr<T>, nullif: <T>(x: EV<T>, y: EV<T>) => Expr<T | null>, prnumberf: (format: string, ...rest: Array<Expr<any>>) => Expr<string>, quote: (x: EV<string>) => Expr<string>, random: () => Expr<number>, replace: (x: EV<string>, y: EV<string>, z: EV<string>) => Expr<string>, round: (x: EV<number>, y?: EV<number>) => Expr<number>, rtrim: (x: EV<string>, y?: EV<string>) => Expr<string>, sign: (x: EV<number>) => Expr<number>, soundex: (x: EV<string>) => Expr<string>, sqlite_version: () => Expr<string>, substr: (x: EV<string>, y: EV<number>, z?: EV<number>) => Expr<string>, total_changes: () => Expr<number>, trim: (x: EV<string>, Y: EV<string>) => Expr<string>, unicode: (x: EV<string>) => Expr<number>, unlikely: (x: EV<boolean>) => Expr<boolean>, upper: (x: EV<string>) => Expr<string>, avg: (x: Expr<number>) => Expr<number>, group_concat: (x: EV<string>, y: EV<string>) => Expr<string>, sum: (x: EV<number>) => Expr<number>, acos: (x: EV<number>) => Expr<number>, acosh: (x: EV<number>) => Expr<number>, asin: (x: EV<number>) => Expr<number>, asinh: (x: EV<number>) => Expr<number>, atan: (x: EV<number>) => Expr<number>, atan2: (x: EV<number>, y: EV<number>) => Expr<number>, atanh: (x: EV<number>) => Expr<number>, ceil: (x: EV<number>) => Expr<number>, cos: (x: EV<number>) => Expr<number>, cosh: (x: EV<number>) => Expr<number>, degrees: (x: EV<number>) => Expr<number>, exp: (x: EV<number>) => Expr<number>, floor: (x: EV<number>) => Expr<number>, ln: (x: EV<number>) => Expr<number>, log: (x: EV<number>, y?: EV<number>) => Expr<number>, log2: (x: EV<number>) => Expr<number>, mod: (x: EV<number>, y: EV<number>) => Expr<number>, pi: (x: EV<number>) => Expr<number>, pow: (x: EV<number>, y: EV<number>) => Expr<number>, radians: (x: EV<number>) => Expr<number>, sin: (x: EV<number>) => Expr<number>, sinh: (x: EV<number>) => Expr<number>, sqrt: (x: EV<number>) => Expr<number>, tan: (x: EV<number>) => Expr<number>, tanh: (x: EV<number>) => Expr<number>, trunc: (x: EV<number>) => Expr<number>, date: (timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>, time: (timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>, datetime: (timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>, julianday: (timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>, strftime: (format: EV<string>, timeValue: EV<any>, ...rest: Array<EV<string>>) => Expr<string>;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { Functions } from "../lib/Functions.js";
|
|
3
3
|
var SqliteFunctions = Functions;
|
|
4
4
|
var {
|
|
5
|
+
count,
|
|
6
|
+
iif,
|
|
7
|
+
exists,
|
|
5
8
|
match,
|
|
6
9
|
cast,
|
|
7
10
|
abs,
|
|
@@ -9,7 +12,6 @@ var {
|
|
|
9
12
|
char,
|
|
10
13
|
coalesce,
|
|
11
14
|
ifnull,
|
|
12
|
-
iif,
|
|
13
15
|
instr,
|
|
14
16
|
last_insert_rowid,
|
|
15
17
|
length,
|
|
@@ -36,7 +38,6 @@ var {
|
|
|
36
38
|
unlikely,
|
|
37
39
|
upper,
|
|
38
40
|
avg,
|
|
39
|
-
count,
|
|
40
41
|
group_concat,
|
|
41
42
|
sum,
|
|
42
43
|
acos,
|
|
@@ -93,6 +94,7 @@ export {
|
|
|
93
94
|
date,
|
|
94
95
|
datetime,
|
|
95
96
|
degrees,
|
|
97
|
+
exists,
|
|
96
98
|
exp,
|
|
97
99
|
floor,
|
|
98
100
|
group_concat,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/sqlite/SqliteSchema.ts
|
|
2
2
|
import { Cursor } from "../lib/Cursor.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Statement } from "../lib/Statement.js";
|
|
4
4
|
import { SqliteFormatter } from "./SqliteFormatter.js";
|
|
5
5
|
var SqliteSchema;
|
|
6
6
|
((SqliteSchema2) => {
|
|
@@ -25,13 +25,16 @@ var SqliteSchema;
|
|
|
25
25
|
}
|
|
26
26
|
SqliteSchema2.createInstructions = createInstructions;
|
|
27
27
|
function columnInstruction(column) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const stmt = new Statement();
|
|
29
|
+
stmt.identifier(column.name).add(column.type);
|
|
30
|
+
if (column.pk === 1)
|
|
31
|
+
stmt.add("PRIMARY KEY");
|
|
32
|
+
if (column.notnull === 1)
|
|
33
|
+
stmt.add("NOT NULL");
|
|
34
|
+
if (column.dflt_value !== null) {
|
|
35
|
+
stmt.add("DEFAULT").space().openParenthesis().raw(column.dflt_value).closeParenthesis();
|
|
36
|
+
}
|
|
37
|
+
return [column.name, stmt.compile(formatter).sql];
|
|
35
38
|
}
|
|
36
39
|
SqliteSchema2.columnInstruction = columnInstruction;
|
|
37
40
|
function indexInstruction(index) {
|