rado 0.1.49 → 0.1.51

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.
Files changed (72) hide show
  1. package/README.md +1 -1
  2. package/dist/define/Column.d.ts +58 -58
  3. package/dist/define/Cursor.d.ts +85 -85
  4. package/dist/define/Expr.d.ts +154 -154
  5. package/dist/define/Fields.d.ts +13 -13
  6. package/dist/define/Functions.d.ts +5 -5
  7. package/dist/define/Id.d.ts +3 -3
  8. package/dist/define/Index.d.ts +17 -17
  9. package/dist/define/Ops.d.ts +7 -7
  10. package/dist/define/OrderBy.d.ts +9 -9
  11. package/dist/define/Param.d.ts +15 -15
  12. package/dist/define/Query.d.ts +109 -109
  13. package/dist/define/Schema.d.ts +18 -18
  14. package/dist/define/Selection.d.ts +20 -20
  15. package/dist/define/Table.d.ts +62 -62
  16. package/dist/define/Target.d.ts +38 -38
  17. package/dist/define/Update.d.ts +4 -4
  18. package/dist/driver/better-sqlite3.d.ts +15 -15
  19. package/dist/driver/better-sqlite3.js +6 -1
  20. package/dist/driver/bun-sqlite.d.ts +18 -18
  21. package/dist/driver/bun-sqlite.js +6 -1
  22. package/dist/driver/sql.js.d.ts +15 -15
  23. package/dist/driver/sql.js.js +10 -5
  24. package/dist/driver/sqlite3.d.ts +18 -18
  25. package/dist/driver/sqlite3.js +6 -1
  26. package/dist/index.d.ts +21 -20
  27. package/dist/index.js +1 -0
  28. package/dist/lib/Driver.d.ts +110 -110
  29. package/dist/lib/Formatter.d.ts +67 -67
  30. package/dist/lib/Formatter.js +5 -5
  31. package/dist/lib/Sanitizer.d.ts +5 -5
  32. package/dist/lib/SqlError.d.ts +4 -0
  33. package/dist/lib/SqlError.js +12 -0
  34. package/dist/lib/Statement.d.ts +29 -29
  35. package/dist/lib/Statement.js +1 -1
  36. package/dist/sqlite/SqliteFormatter.d.ts +11 -11
  37. package/dist/sqlite/SqliteFunctions.d.ts +165 -165
  38. package/dist/sqlite/SqliteSchema.d.ts +25 -25
  39. package/dist/sqlite.d.ts +2 -2
  40. package/package.json +60 -58
  41. package/dist/lib/Column.d.ts +0 -57
  42. package/dist/lib/Column.js +0 -68
  43. package/dist/lib/Cursor.d.ts +0 -85
  44. package/dist/lib/Cursor.js +0 -256
  45. package/dist/lib/Expr.d.ts +0 -154
  46. package/dist/lib/Expr.js +0 -284
  47. package/dist/lib/Fields.d.ts +0 -13
  48. package/dist/lib/Fields.js +0 -0
  49. package/dist/lib/Functions.d.ts +0 -5
  50. package/dist/lib/Functions.js +0 -11
  51. package/dist/lib/Id.d.ts +0 -3
  52. package/dist/lib/Id.js +0 -0
  53. package/dist/lib/Index.d.ts +0 -17
  54. package/dist/lib/Index.js +0 -20
  55. package/dist/lib/Ops.d.ts +0 -7
  56. package/dist/lib/Ops.js +0 -36
  57. package/dist/lib/OrderBy.d.ts +0 -9
  58. package/dist/lib/OrderBy.js +0 -9
  59. package/dist/lib/Param.d.ts +0 -20
  60. package/dist/lib/Param.js +0 -27
  61. package/dist/lib/Query.d.ts +0 -109
  62. package/dist/lib/Query.js +0 -74
  63. package/dist/lib/Schema.d.ts +0 -18
  64. package/dist/lib/Schema.js +0 -67
  65. package/dist/lib/Selection.d.ts +0 -20
  66. package/dist/lib/Selection.js +0 -7
  67. package/dist/lib/Table.d.ts +0 -62
  68. package/dist/lib/Table.js +0 -130
  69. package/dist/lib/Target.d.ts +0 -38
  70. package/dist/lib/Target.js +0 -42
  71. package/dist/lib/Update.d.ts +0 -4
  72. package/dist/lib/Update.js +0 -0
@@ -72,7 +72,7 @@ var Formatter = class {
72
72
  }
73
73
  formatSelect(ctx, query) {
74
74
  const { stmt, topLevel } = ctx;
75
- stmt.add("SELECT").space();
75
+ stmt.raw("SELECT").space();
76
76
  this.formatSelection(
77
77
  { ...ctx, topLevel: false },
78
78
  query.selection,
@@ -325,7 +325,7 @@ var Formatter = class {
325
325
  case TargetType.Table:
326
326
  stmt.identifier(target.table.name);
327
327
  if (target.table.alias)
328
- stmt.raw("AS").addIdentifier(target.table.alias);
328
+ stmt.add("AS").addIdentifier(target.table.alias);
329
329
  return stmt;
330
330
  case TargetType.Join:
331
331
  const { left, right, joinType } = target;
@@ -340,7 +340,7 @@ var Formatter = class {
340
340
  this.format(ctx, target.query);
341
341
  stmt.closeParenthesis();
342
342
  if (target.alias)
343
- stmt.raw("AS").addIdentifier(target.alias);
343
+ stmt.add("AS").addIdentifier(target.alias);
344
344
  return stmt;
345
345
  case TargetType.Expr:
346
346
  throw new Error("Cannot format expression as target");
@@ -375,7 +375,7 @@ var Formatter = class {
375
375
  const { stmt } = ctx;
376
376
  if (!orderBy)
377
377
  return stmt;
378
- stmt.newline().raw("ORDER BY");
378
+ stmt.newline().raw("ORDER BY").space();
379
379
  for (const { expr, order } of stmt.separate(orderBy)) {
380
380
  this.formatExprValue(ctx, expr);
381
381
  stmt.add(order === OrderDirection.Asc ? "ASC" : "DESC");
@@ -572,7 +572,7 @@ var Formatter = class {
572
572
  this.format(ctx, expr.query);
573
573
  return stmt.closeParenthesis().closeParenthesis();
574
574
  }
575
- stmt.openParenthesis().raw("SELECT json_group_array(json(result))").newline().raw("FROM").openParenthesis();
575
+ stmt.openParenthesis().raw("SELECT json_group_array(json(result))").newline().raw("FROM").space().openParenthesis();
576
576
  this.format(ctx, expr.query);
577
577
  return stmt.closeParenthesis().closeParenthesis();
578
578
  case ExprType.Row:
@@ -1,5 +1,5 @@
1
- export interface Sanitizer {
2
- escapeValue(value: any): string;
3
- escapeIdentifier(ident: string): string;
4
- formatParamValue(paramValue: any): any;
5
- }
1
+ export interface Sanitizer {
2
+ escapeValue(value: any): string;
3
+ escapeIdentifier(ident: string): string;
4
+ formatParamValue(paramValue: any): any;
5
+ }
@@ -0,0 +1,4 @@
1
+ export declare class SqlError extends Error {
2
+ sql: string;
3
+ constructor(cause: Error, sql: string);
4
+ }
@@ -0,0 +1,12 @@
1
+ // src/lib/SqlError.ts
2
+ var SqlError = class extends Error {
3
+ constructor(cause, sql) {
4
+ super(`${sql}
5
+ \u2502
6
+ \u2514\u2500\u2500\u2500\u2500 ${cause}`, { cause });
7
+ this.sql = sql;
8
+ }
9
+ };
10
+ export {
11
+ SqlError
12
+ };
@@ -1,29 +1,29 @@
1
- import { ParamData } from '../define/Param';
2
- import { Sanitizer } from './Sanitizer';
3
- export declare class Statement {
4
- sanitizer: Sanitizer;
5
- sql: string;
6
- private paramData;
7
- currentIndent: string;
8
- constructor(sanitizer: Sanitizer, sql?: string, paramData?: Array<ParamData>);
9
- space(): this;
10
- add(addition: undefined | string): this;
11
- addLine(addition: undefined | string): this;
12
- indent(): this;
13
- dedent(): this;
14
- newline(): this;
15
- identifier(name: string): this;
16
- addIdentifier(name: string): this;
17
- value(value: any): this;
18
- addValue(value: any): this;
19
- param(name: string): this;
20
- addParam(name: string): this;
21
- raw(query: string): this;
22
- openParenthesis(): this;
23
- closeParenthesis(): this;
24
- call<T>(parts: Array<T>, separator?: string): Generator<T, this | undefined, unknown>;
25
- separate<T>(parts: Array<T>, separator?: string): Generator<T, void, unknown>;
26
- isEmpty(): boolean;
27
- params(input?: Record<string, any>): Array<any>;
28
- toString(): string;
29
- }
1
+ import { ParamData } from '../define/Param';
2
+ import { Sanitizer } from './Sanitizer';
3
+ export declare class Statement {
4
+ sanitizer: Sanitizer;
5
+ sql: string;
6
+ private paramData;
7
+ currentIndent: string;
8
+ constructor(sanitizer: Sanitizer, sql?: string, paramData?: Array<ParamData>);
9
+ space(): this;
10
+ add(addition: undefined | string): this;
11
+ addLine(addition: undefined | string): this;
12
+ indent(): this;
13
+ dedent(): this;
14
+ newline(): this;
15
+ identifier(name: string): this;
16
+ addIdentifier(name: string): this;
17
+ value(value: any): this;
18
+ addValue(value: any): this;
19
+ param(name: string): this;
20
+ addParam(name: string): this;
21
+ raw(query: string): this;
22
+ openParenthesis(): this;
23
+ closeParenthesis(): this;
24
+ call<T>(parts: Array<T>, separator?: string): Generator<T, this | undefined, unknown>;
25
+ separate<T>(parts: Array<T>, separator?: string): Generator<T, void, unknown>;
26
+ isEmpty(): boolean;
27
+ params(input?: Record<string, any>): Array<any>;
28
+ toString(): string;
29
+ }
@@ -24,7 +24,7 @@ var Statement = class {
24
24
  addLine(addition) {
25
25
  if (!addition)
26
26
  return this;
27
- return this.newline().add(addition);
27
+ return this.newline().raw(addition);
28
28
  }
29
29
  indent() {
30
30
  this.currentIndent = this.currentIndent + " ";
@@ -1,11 +1,11 @@
1
- import { ExprData } from '../define/Expr';
2
- import { FormatContext, Formatter } from '../lib/Formatter';
3
- import { Statement } from '../lib/Statement';
4
- export declare class SqliteFormatter extends Formatter {
5
- formatParamValue(paramValue: any): any;
6
- escapeValue(value: any): string;
7
- escapeIdentifier(input: string): string;
8
- escapeString(input: string): string;
9
- formatAccess(ctx: FormatContext, mkSubject: () => void, field: string): Statement;
10
- formatExpr(ctx: FormatContext, expr: ExprData): Statement;
11
- }
1
+ import { ExprData } from '../define/Expr';
2
+ import { FormatContext, Formatter } from '../lib/Formatter';
3
+ import { Statement } from '../lib/Statement';
4
+ export declare class SqliteFormatter extends Formatter {
5
+ formatParamValue(paramValue: any): any;
6
+ escapeValue(value: any): string;
7
+ escapeIdentifier(input: string): string;
8
+ escapeString(input: string): string;
9
+ formatAccess(ctx: FormatContext, mkSubject: () => void, field: string): Statement;
10
+ formatExpr(ctx: FormatContext, expr: ExprData): Statement;
11
+ }
@@ -1,165 +1,165 @@
1
- import { Cursor } from '../define/Cursor';
2
- import { EV, Expr } from '../define/Expr';
3
- import { Table } from '../define/Table';
4
- export declare const SqliteFunctions: SqliteFunctions;
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>;
14
- /** Use the match operator for the FTS5 module */
15
- match(table: Table<any>, searchTerm: EV<string>): Expr<boolean>;
16
- /** The highlight() function returns a copy of the text from a specified column of the current row with extra markup text inserted to mark the start and end of phrase matches. */
17
- highlight(table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>): Expr<string>;
18
- /** The snippet() function is similar to highlight(), except that instead of returning entire column values, it automatically selects and extracts a short fragment of document text to process and return. */
19
- snippet(table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>, snip: EV<string>, maxTokens: EV<number>): Expr<string>;
20
- cast(x: EV<any>, type: 'text'): Expr<string>;
21
- cast(x: EV<any>, type: 'real'): Expr<number>;
22
- cast(x: EV<any>, type: 'integer'): Expr<number>;
23
- cast(x: EV<any>, type: 'numeric'): Expr<number>;
24
- /** The abs(X) function returns the absolute value of the numeric argument X. Abs(X) returns NULL if X is NULL. Abs(X) returns 0.0 if X is a string or blob that cannot be converted to a numeric value. If X is the numbereger -9223372036854775808 then abs(X) throws an numbereger overflow error since there is no equivalent positive 64-bit two complement value.*/
25
- abs(x: EV<number>): Expr<number>;
26
- /** The changes() function returns the number of database rows that were changed or inserted or deleted by the most recently completed INSERT, DELETE, or UPDATE statement, exclusive of statements in lower-level triggers. The changes() SQL function is a wrapper around the sqlite3_changes() C/C++ function and hence follows the same rules for counting changes.*/
27
- changes(): Expr<number>;
28
- /** The char(X1,X2,...,XN) function returns a string composed of characters having the unicode code ponumber values of numberegers X1 through XN, respectively.*/
29
- char(...arg: Array<EV<number>>): Expr<string>;
30
- /** The coalesce() function returns a copy of its first non-NULL argument, or NULL if all arguments are NULL. Coalesce() must have at least 2 arguments.*/
31
- coalesce(x: EV<any>, y: EV<any>, ...rest: EV<any>): Expr<any>;
32
- /** 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".*/
33
- /** 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.*/
34
- ifnull<T>(x: EV<T>, y: EV<T>): Expr<T>;
35
- /** 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.*/
36
- instr(x: EV<string>, y: EV<string>): Expr<number>;
37
- /** 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.*/
38
- last_insert_rowid(): Expr<number>;
39
- /** For a string value X, the length(X) function returns the number of characters (not bytes) in X prior to the first NUL character. Since SQLite strings do not normally contain NUL characters, the length(X) function will usually return the total number of characters in the string X. For a blob value X, length(X) returns the number of bytes in the blob. If X is NULL then length(X) is NULL. If X is numeric then length(X) returns the length of a string representation of X.*/
40
- length(x: EV<string>): Expr<number>;
41
- /** The likelihood(X,Y) function returns argument X unchanged. The value Y in likelihood(X,Y) must be a numbering ponumber constant between 0.0 and 1.0, inclusive. The likelihood(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles during run-time (that is, during calls to sqlite3_step()). The purpose of the likelihood(X,Y) function is to provide a hnumber to the query planner that the argument X is a boolean that is true with a probability of approximately Y. The unlikely(X) function is short-hand for likelihood(X,0.0625). The likely(X) function is short-hand for likelihood(X,0.9375).*/
42
- likelihood(x: EV<boolean>, y: number): Expr<boolean>;
43
- /** The likely(X) function returns the argument X unchanged. The likely(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles at run-time (that is, during calls to sqlite3_step()). The purpose of the likely(X) function is to provide a hnumber to the query planner that the argument X is a boolean value that is usually true. The likely(X) function is equivalent to likelihood(X,0.9375). See also: unlikely(X).*/
44
- likely(x: EV<boolean>): Expr<boolean>;
45
- /** The lower(X) function returns a copy of string X with all ASCII characters converted to lower case. The default built-in lower() function works for ASCII characters only. To do case conversions on non-ASCII characters, load the ICU extension.*/
46
- lower(x: EV<string>): Expr<string>;
47
- /** The ltrim(X,Y) function returns a string formed by removing any and all characters that appear in Y from the left side of X. If the Y argument is omitted, ltrim(X) removes spaces from the left side of X.**/
48
- ltrim(x: EV<string>, y?: EV<string>): Expr<string>;
49
- /** The multi-argument max() function returns the argument with the maximum value, or return NULL if any argument is NULL. The multi-argument max() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to max() define a collating function, then the BINARY collating function is used. Note that max() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument.*/
50
- max<T>(x: EV<T>, ...rest: Array<EV<T>>): Expr<T>;
51
- /** The multi-argument min() function returns the argument with the minimum value. The multi-argument min() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to min() define a collating function, then the BINARY collating function is used. Note that min() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument.*/
52
- min<T>(x: EV<T>, ...rest: Array<EV<T>>): Expr<T>;
53
- /** The nullif(X,Y) function returns its first argument if the arguments are different and NULL if the arguments are the same. The nullif(X,Y) function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If neither argument to nullif() defines a collating function then the BINARY is used.*/
54
- nullif<T>(x: EV<T>, y: EV<T>): Expr<T | null>;
55
- /** The prnumberf(FORMAT,...) SQL function works like the sqlite3_mprnumberf() C-language function and the prnumberf() function from the standard C library. The first argument is a format string that specifies how to construct the output string using values taken from subsequent arguments. If the FORMAT argument is missing or NULL then the result is NULL. The %n format is silently ignored and does not consume an argument. The %p format is an alias for %X. The %z format is numbererchangeable with %s. If there are too few arguments in the argument list, missing arguments are assumed to have a NULL value, which is translated numbero 0 or 0.0 for numeric formats or an empty string for %s. See the built-in prnumberf() documentation for additional information.*/
56
- prnumberf(format: string, ...rest: Array<Expr<any>>): Expr<string>;
57
- /** The quote(X) function returns the text of an SQL literal which is the value of its argument suitable for inclusion numbero an SQL statement. strings are surrounded by single-quotes with escapes on numbererior quotes as needed. BLOBs are encoded as hexadecimal literals. strings with embedded NUL characters cannot be represented as string literals in SQL and hence the returned string literal is truncated prior to the first NUL.*/
58
- quote(x: EV<string>): Expr<string>;
59
- /** The random() function returns a pseudo-random numbereger between -9223372036854775808 and +9223372036854775807.*/
60
- random(): Expr<number>;
61
- /** The randomblob(N) function return an N-byte blob containing pseudo-random bytes. If N is less than 1 then a 1-byte random blob is returned.*/
62
- /** The replace(X,Y,Z) function returns a string formed by substituting string Z for every occurrence of string Y in string X. The BINARY collating sequence is used for comparisons. If Y is an empty string then return X unchanged. If Z is not initially a string, it is cast to a UTF-8 string prior to processing.*/
63
- replace(x: EV<string>, y: EV<string>, z: EV<string>): Expr<string>;
64
- /** The round(X,Y) function returns a numbering-ponumber value X rounded to Y digits to the right of the decimal ponumber. If the Y argument is omitted, it is assumed to be 0.*/
65
- round(x: EV<number>, y?: EV<number>): Expr<number>;
66
- /** The rtrim(X,Y) function returns a string formed by removing any and all characters that appear in Y from the right side of X. If the Y argument is omitted, rtrim(X) removes spaces from the right side of X.*/
67
- rtrim(x: EV<string>, y?: EV<string>): Expr<string>;
68
- /** The sign(X) function returns -1, 0, or +1 if the argument X is a numeric value that is negative, zero, or positive, respectively. If the argument to sign(X) is NULL or is a string or blob that cannot be losslessly converted numbero a number, then sign(X) return NULL.*/
69
- sign(x: EV<number>): Expr<number>;
70
- /** The soundex(X) function returns a string that is the soundex encoding of the string X. The string "?000" is returned if the argument is NULL or contains no ASCII alphabetic characters. This function is omitted from SQLite by default. It is only available if the SQLITE_SOUNDEX compile-time option is used when SQLite is built.*/
71
- soundex(x: EV<string>): Expr<string>;
72
- /** The sqlite_version() function returns the version string for the SQLite library that is running. This function is an SQL wrapper around the sqlite3_libversion() C-numbererface.*/
73
- sqlite_version(): Expr<string>;
74
- /** The substr(X,Y,Z) function returns a substring of input string X that begins with the Y-th character and which is Z characters long. If Z is omitted then substr(X,Y) returns all characters through the end of the string X beginning with the Y-th. The left-most character of X is number 1. If Y is negative then the first character of the substring is found by counting from the right rather than the left. If Z is negative then the abs(Z) characters preceding the Y-th character are returned. If X is a string then characters indices refer to actual UTF-8 characters. If X is a BLOB then the indices refer to bytes.*/
75
- substr(x: EV<string>, y: EV<number>, z?: EV<number>): Expr<string>;
76
- /** The total_changes() function returns the number of row changes caused by INSERT, UPDATE or DELETE statements since the current database connection was opened. This function is a wrapper around the sqlite3_total_changes() C/C++ numbererface.*/
77
- total_changes(): Expr<number>;
78
- /** The trim(X,Y) function returns a string formed by removing any and all characters that appear in Y from both ends of X. If the Y argument is omitted, trim(X) removes spaces from both ends of X.*/
79
- trim(x: EV<string>, Y: EV<string>): Expr<string>;
80
- /** The typeof(X) function returns a string that indicates the datatype of the Expr X: "null", "numbereger", "real", "text", or "blob".*/
81
- typeof(x: EV<any>): Expr<string>;
82
- /** The unicode(X) function returns the numeric unicode code ponumber corresponding to the first character of the string X. If the argument to unicode(X) is not a string then the result is undefined.*/
83
- unicode(x: EV<string>): Expr<number>;
84
- /** The unlikely(X) function returns the argument X unchanged. The unlikely(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles at run-time (that is, during calls to sqlite3_step()). The purpose of the unlikely(X) function is to provide a hnumber to the query planner that the argument X is a boolean value that is usually not true. The unlikely(X) function is equivalent to likelihood(X, 0.0625).*/
85
- unlikely(x: EV<boolean>): Expr<boolean>;
86
- /** The upper(X) function returns a copy of input string X in which all lower-case ASCII characters are converted to their upper-case equivalent.*/
87
- upper(x: EV<string>): Expr<string>;
88
- /** 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. */
89
- avg(x: Expr<number>): Expr<number>;
90
- /** 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. */
91
- group_concat(x: EV<string>, y: EV<string>): Expr<string>;
92
- /** 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.
93
-
94
- The result of total() is always a numbering ponumber value. The result of sum() is an numbereger value if all non-NULL inputs are numberegers. If any input to sum() is neither an numbereger or a NULL then sum() returns a numbering ponumber value which might be an approximation to the true sum.
95
-
96
- Sum() will throw an "numbereger overflow" exception if all inputs are numberegers or NULL and an numbereger overflow occurs at any ponumber during the computation. Total() never throws an numbereger overflow.
97
- */
98
- sum(x: EV<number>): Expr<number>;
99
- /** Return the arccosine of X. The result is in radians. */
100
- acos(x: EV<number>): Expr<number>;
101
- /** Return the hyperbolic arccosine of X. */
102
- acosh(x: EV<number>): Expr<number>;
103
- /** Return the arcsine of X. The result is in radians. */
104
- asin(x: EV<number>): Expr<number>;
105
- /** Return the hyperbolic arcsine of X. */
106
- asinh(x: EV<number>): Expr<number>;
107
- /** Return the arctangent of X. The result is in radians. */
108
- atan(x: EV<number>): Expr<number>;
109
- /** Return the arctangent of Y/X. The result is in radians. The result is placed numbero correct quadrant depending on the signs of X and Y. */
110
- atan2(x: EV<number>, y: EV<number>): Expr<number>;
111
- /** Return the hyperbolic arctangent of X. */
112
- atanh(x: EV<number>): Expr<number>;
113
- /** Return the first representable numbereger value greater than or equal to X. For positive values of X, this routine rounds away from zero. For negative values of X, this routine rounds toward zero. */
114
- ceil(x: EV<number>): Expr<number>;
115
- /** Return the cosine of X. X is in radians. */
116
- cos(x: EV<number>): Expr<number>;
117
- /** Return the hyperbolic cosine of X. */
118
- cosh(x: EV<number>): Expr<number>;
119
- /** Convert value X from radians numbero degrees. */
120
- degrees(x: EV<number>): Expr<number>;
121
- /** Compute e (Euler's number, approximately 2.71828182845905) raised to the power X. */
122
- exp(x: EV<number>): Expr<number>;
123
- /** Return the first representable numbereger value less than or equal to X. For positive numbers, this function rounds toward zero. For negative numbers, this function rounds away from zero. */
124
- floor(x: EV<number>): Expr<number>;
125
- /** Return the natural logarithm of X. */
126
- ln(x: EV<number>): Expr<number>;
127
- /**
128
- Return the base-10 logarithm for X. Or, for the two-argument version, return the base-B logarithm of X.
129
- Compatibility note: SQLite works like PostgreSQL in that the log() function computes a base-10 logarithm. Most other SQL database engines compute a natural logarithm for log(). In the two-argument version of log(B,X), the first argument is the base and the second argument is the operand. This is the same as in PostgreSQL and MySQL, but is reversed from SQL Server which uses the second argument as the base and the first argument as the operand.
130
- */
131
- log(x: EV<number>, y?: EV<number>): Expr<number>;
132
- /** Return the logarithm base-2 for the number X. */
133
- log2(x: EV<number>): Expr<number>;
134
- /** Return the remainder after dividing X by Y. This is similar to the '%' operator, except that it works for non-numbereger arguments. */
135
- mod(x: EV<number>, y: EV<number>): Expr<number>;
136
- /** Return an approximation for π. */
137
- pi(x: EV<number>): Expr<number>;
138
- /** Compute X raised to the power Y. */
139
- pow(x: EV<number>, y: EV<number>): Expr<number>;
140
- /** Convert X from degrees numbero radians. */
141
- radians(x: EV<number>): Expr<number>;
142
- /** Return the sine of X. X is in radians. */
143
- sin(x: EV<number>): Expr<number>;
144
- /** Return the hyperbolic sine of X. */
145
- sinh(x: EV<number>): Expr<number>;
146
- /** Return the square root of X. NULL is returned if X is negative. */
147
- sqrt(x: EV<number>): Expr<number>;
148
- /** Return the tangent of X. X is in radians. */
149
- tan(x: EV<number>): Expr<number>;
150
- /** Return the hyperbolic tangent of X. */
151
- tanh(x: EV<number>): Expr<number>;
152
- /** Return the representable numbereger in between X and 0 (inclusive) that is furthest away from zero. Or, in other words, return the numbereger part of X, rounding toward zero. The trunc() function is similar to ceiling(X) and floor(X) except that it always rounds toward zero whereas ceiling(X) and floor(X) round up and down, respectively. */
153
- trunc(x: EV<number>): Expr<number>;
154
- date(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
155
- time(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
156
- datetime(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
157
- julianday(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
158
- strftime(format: EV<string>, timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
159
- };
160
- 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>, highlight: (table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>) => Expr<string>, snippet: (table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>, snip: EV<string>, maxTokens: EV<number>) => Expr<string>, cast: {
161
- (x: EV<any>, type: 'text'): Expr<string>;
162
- (x: EV<any>, type: 'real'): Expr<number>;
163
- (x: EV<any>, type: 'integer'): Expr<number>;
164
- (x: EV<any>, type: 'numeric'): Expr<number>;
165
- }, 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>, ...rest: EV<T>[]) => Expr<T>, min: <T>(x: 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>;
1
+ import { Cursor } from '../define/Cursor';
2
+ import { EV, Expr } from '../define/Expr';
3
+ import { Table } from '../define/Table';
4
+ export declare const SqliteFunctions: SqliteFunctions;
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>;
14
+ /** Use the match operator for the FTS5 module */
15
+ match(table: Table<any>, searchTerm: EV<string>): Expr<boolean>;
16
+ /** The highlight() function returns a copy of the text from a specified column of the current row with extra markup text inserted to mark the start and end of phrase matches. */
17
+ highlight(table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>): Expr<string>;
18
+ /** The snippet() function is similar to highlight(), except that instead of returning entire column values, it automatically selects and extracts a short fragment of document text to process and return. */
19
+ snippet(table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>, snip: EV<string>, maxTokens: EV<number>): Expr<string>;
20
+ cast(x: EV<any>, type: 'text'): Expr<string>;
21
+ cast(x: EV<any>, type: 'real'): Expr<number>;
22
+ cast(x: EV<any>, type: 'integer'): Expr<number>;
23
+ cast(x: EV<any>, type: 'numeric'): Expr<number>;
24
+ /** The abs(X) function returns the absolute value of the numeric argument X. Abs(X) returns NULL if X is NULL. Abs(X) returns 0.0 if X is a string or blob that cannot be converted to a numeric value. If X is the numbereger -9223372036854775808 then abs(X) throws an numbereger overflow error since there is no equivalent positive 64-bit two complement value.*/
25
+ abs(x: EV<number>): Expr<number>;
26
+ /** The changes() function returns the number of database rows that were changed or inserted or deleted by the most recently completed INSERT, DELETE, or UPDATE statement, exclusive of statements in lower-level triggers. The changes() SQL function is a wrapper around the sqlite3_changes() C/C++ function and hence follows the same rules for counting changes.*/
27
+ changes(): Expr<number>;
28
+ /** The char(X1,X2,...,XN) function returns a string composed of characters having the unicode code ponumber values of numberegers X1 through XN, respectively.*/
29
+ char(...arg: Array<EV<number>>): Expr<string>;
30
+ /** The coalesce() function returns a copy of its first non-NULL argument, or NULL if all arguments are NULL. Coalesce() must have at least 2 arguments.*/
31
+ coalesce(x: EV<any>, y: EV<any>, ...rest: EV<any>): Expr<any>;
32
+ /** 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".*/
33
+ /** 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.*/
34
+ ifnull<T>(x: EV<T>, y: EV<T>): Expr<T>;
35
+ /** 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.*/
36
+ instr(x: EV<string>, y: EV<string>): Expr<number>;
37
+ /** 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.*/
38
+ last_insert_rowid(): Expr<number>;
39
+ /** For a string value X, the length(X) function returns the number of characters (not bytes) in X prior to the first NUL character. Since SQLite strings do not normally contain NUL characters, the length(X) function will usually return the total number of characters in the string X. For a blob value X, length(X) returns the number of bytes in the blob. If X is NULL then length(X) is NULL. If X is numeric then length(X) returns the length of a string representation of X.*/
40
+ length(x: EV<string>): Expr<number>;
41
+ /** The likelihood(X,Y) function returns argument X unchanged. The value Y in likelihood(X,Y) must be a numbering ponumber constant between 0.0 and 1.0, inclusive. The likelihood(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles during run-time (that is, during calls to sqlite3_step()). The purpose of the likelihood(X,Y) function is to provide a hnumber to the query planner that the argument X is a boolean that is true with a probability of approximately Y. The unlikely(X) function is short-hand for likelihood(X,0.0625). The likely(X) function is short-hand for likelihood(X,0.9375).*/
42
+ likelihood(x: EV<boolean>, y: number): Expr<boolean>;
43
+ /** The likely(X) function returns the argument X unchanged. The likely(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles at run-time (that is, during calls to sqlite3_step()). The purpose of the likely(X) function is to provide a hnumber to the query planner that the argument X is a boolean value that is usually true. The likely(X) function is equivalent to likelihood(X,0.9375). See also: unlikely(X).*/
44
+ likely(x: EV<boolean>): Expr<boolean>;
45
+ /** The lower(X) function returns a copy of string X with all ASCII characters converted to lower case. The default built-in lower() function works for ASCII characters only. To do case conversions on non-ASCII characters, load the ICU extension.*/
46
+ lower(x: EV<string>): Expr<string>;
47
+ /** The ltrim(X,Y) function returns a string formed by removing any and all characters that appear in Y from the left side of X. If the Y argument is omitted, ltrim(X) removes spaces from the left side of X.**/
48
+ ltrim(x: EV<string>, y?: EV<string>): Expr<string>;
49
+ /** The multi-argument max() function returns the argument with the maximum value, or return NULL if any argument is NULL. The multi-argument max() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to max() define a collating function, then the BINARY collating function is used. Note that max() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument.*/
50
+ max<T>(x: EV<T>, ...rest: Array<EV<T>>): Expr<T>;
51
+ /** The multi-argument min() function returns the argument with the minimum value. The multi-argument min() function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If none of the arguments to min() define a collating function, then the BINARY collating function is used. Note that min() is a simple function when it has 2 or more arguments but operates as an aggregate function if given only a single argument.*/
52
+ min<T>(x: EV<T>, ...rest: Array<EV<T>>): Expr<T>;
53
+ /** The nullif(X,Y) function returns its first argument if the arguments are different and NULL if the arguments are the same. The nullif(X,Y) function searches its arguments from left to right for an argument that defines a collating function and uses that collating function for all string comparisons. If neither argument to nullif() defines a collating function then the BINARY is used.*/
54
+ nullif<T>(x: EV<T>, y: EV<T>): Expr<T | null>;
55
+ /** The prnumberf(FORMAT,...) SQL function works like the sqlite3_mprnumberf() C-language function and the prnumberf() function from the standard C library. The first argument is a format string that specifies how to construct the output string using values taken from subsequent arguments. If the FORMAT argument is missing or NULL then the result is NULL. The %n format is silently ignored and does not consume an argument. The %p format is an alias for %X. The %z format is numbererchangeable with %s. If there are too few arguments in the argument list, missing arguments are assumed to have a NULL value, which is translated numbero 0 or 0.0 for numeric formats or an empty string for %s. See the built-in prnumberf() documentation for additional information.*/
56
+ prnumberf(format: string, ...rest: Array<Expr<any>>): Expr<string>;
57
+ /** The quote(X) function returns the text of an SQL literal which is the value of its argument suitable for inclusion numbero an SQL statement. strings are surrounded by single-quotes with escapes on numbererior quotes as needed. BLOBs are encoded as hexadecimal literals. strings with embedded NUL characters cannot be represented as string literals in SQL and hence the returned string literal is truncated prior to the first NUL.*/
58
+ quote(x: EV<string>): Expr<string>;
59
+ /** The random() function returns a pseudo-random numbereger between -9223372036854775808 and +9223372036854775807.*/
60
+ random(): Expr<number>;
61
+ /** The randomblob(N) function return an N-byte blob containing pseudo-random bytes. If N is less than 1 then a 1-byte random blob is returned.*/
62
+ /** The replace(X,Y,Z) function returns a string formed by substituting string Z for every occurrence of string Y in string X. The BINARY collating sequence is used for comparisons. If Y is an empty string then return X unchanged. If Z is not initially a string, it is cast to a UTF-8 string prior to processing.*/
63
+ replace(x: EV<string>, y: EV<string>, z: EV<string>): Expr<string>;
64
+ /** The round(X,Y) function returns a numbering-ponumber value X rounded to Y digits to the right of the decimal ponumber. If the Y argument is omitted, it is assumed to be 0.*/
65
+ round(x: EV<number>, y?: EV<number>): Expr<number>;
66
+ /** The rtrim(X,Y) function returns a string formed by removing any and all characters that appear in Y from the right side of X. If the Y argument is omitted, rtrim(X) removes spaces from the right side of X.*/
67
+ rtrim(x: EV<string>, y?: EV<string>): Expr<string>;
68
+ /** The sign(X) function returns -1, 0, or +1 if the argument X is a numeric value that is negative, zero, or positive, respectively. If the argument to sign(X) is NULL or is a string or blob that cannot be losslessly converted numbero a number, then sign(X) return NULL.*/
69
+ sign(x: EV<number>): Expr<number>;
70
+ /** The soundex(X) function returns a string that is the soundex encoding of the string X. The string "?000" is returned if the argument is NULL or contains no ASCII alphabetic characters. This function is omitted from SQLite by default. It is only available if the SQLITE_SOUNDEX compile-time option is used when SQLite is built.*/
71
+ soundex(x: EV<string>): Expr<string>;
72
+ /** The sqlite_version() function returns the version string for the SQLite library that is running. This function is an SQL wrapper around the sqlite3_libversion() C-numbererface.*/
73
+ sqlite_version(): Expr<string>;
74
+ /** The substr(X,Y,Z) function returns a substring of input string X that begins with the Y-th character and which is Z characters long. If Z is omitted then substr(X,Y) returns all characters through the end of the string X beginning with the Y-th. The left-most character of X is number 1. If Y is negative then the first character of the substring is found by counting from the right rather than the left. If Z is negative then the abs(Z) characters preceding the Y-th character are returned. If X is a string then characters indices refer to actual UTF-8 characters. If X is a BLOB then the indices refer to bytes.*/
75
+ substr(x: EV<string>, y: EV<number>, z?: EV<number>): Expr<string>;
76
+ /** The total_changes() function returns the number of row changes caused by INSERT, UPDATE or DELETE statements since the current database connection was opened. This function is a wrapper around the sqlite3_total_changes() C/C++ numbererface.*/
77
+ total_changes(): Expr<number>;
78
+ /** The trim(X,Y) function returns a string formed by removing any and all characters that appear in Y from both ends of X. If the Y argument is omitted, trim(X) removes spaces from both ends of X.*/
79
+ trim(x: EV<string>, Y: EV<string>): Expr<string>;
80
+ /** The typeof(X) function returns a string that indicates the datatype of the Expr X: "null", "numbereger", "real", "text", or "blob".*/
81
+ typeof(x: EV<any>): Expr<string>;
82
+ /** The unicode(X) function returns the numeric unicode code ponumber corresponding to the first character of the string X. If the argument to unicode(X) is not a string then the result is undefined.*/
83
+ unicode(x: EV<string>): Expr<number>;
84
+ /** The unlikely(X) function returns the argument X unchanged. The unlikely(X) function is a no-op that the code generator optimizes away so that it consumes no CPU cycles at run-time (that is, during calls to sqlite3_step()). The purpose of the unlikely(X) function is to provide a hnumber to the query planner that the argument X is a boolean value that is usually not true. The unlikely(X) function is equivalent to likelihood(X, 0.0625).*/
85
+ unlikely(x: EV<boolean>): Expr<boolean>;
86
+ /** The upper(X) function returns a copy of input string X in which all lower-case ASCII characters are converted to their upper-case equivalent.*/
87
+ upper(x: EV<string>): Expr<string>;
88
+ /** 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. */
89
+ avg(x: Expr<number>): Expr<number>;
90
+ /** 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. */
91
+ group_concat(x: EV<string>, y: EV<string>): Expr<string>;
92
+ /** 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.
93
+
94
+ The result of total() is always a numbering ponumber value. The result of sum() is an numbereger value if all non-NULL inputs are numberegers. If any input to sum() is neither an numbereger or a NULL then sum() returns a numbering ponumber value which might be an approximation to the true sum.
95
+
96
+ Sum() will throw an "numbereger overflow" exception if all inputs are numberegers or NULL and an numbereger overflow occurs at any ponumber during the computation. Total() never throws an numbereger overflow.
97
+ */
98
+ sum(x: EV<number>): Expr<number>;
99
+ /** Return the arccosine of X. The result is in radians. */
100
+ acos(x: EV<number>): Expr<number>;
101
+ /** Return the hyperbolic arccosine of X. */
102
+ acosh(x: EV<number>): Expr<number>;
103
+ /** Return the arcsine of X. The result is in radians. */
104
+ asin(x: EV<number>): Expr<number>;
105
+ /** Return the hyperbolic arcsine of X. */
106
+ asinh(x: EV<number>): Expr<number>;
107
+ /** Return the arctangent of X. The result is in radians. */
108
+ atan(x: EV<number>): Expr<number>;
109
+ /** Return the arctangent of Y/X. The result is in radians. The result is placed numbero correct quadrant depending on the signs of X and Y. */
110
+ atan2(x: EV<number>, y: EV<number>): Expr<number>;
111
+ /** Return the hyperbolic arctangent of X. */
112
+ atanh(x: EV<number>): Expr<number>;
113
+ /** Return the first representable numbereger value greater than or equal to X. For positive values of X, this routine rounds away from zero. For negative values of X, this routine rounds toward zero. */
114
+ ceil(x: EV<number>): Expr<number>;
115
+ /** Return the cosine of X. X is in radians. */
116
+ cos(x: EV<number>): Expr<number>;
117
+ /** Return the hyperbolic cosine of X. */
118
+ cosh(x: EV<number>): Expr<number>;
119
+ /** Convert value X from radians numbero degrees. */
120
+ degrees(x: EV<number>): Expr<number>;
121
+ /** Compute e (Euler's number, approximately 2.71828182845905) raised to the power X. */
122
+ exp(x: EV<number>): Expr<number>;
123
+ /** Return the first representable numbereger value less than or equal to X. For positive numbers, this function rounds toward zero. For negative numbers, this function rounds away from zero. */
124
+ floor(x: EV<number>): Expr<number>;
125
+ /** Return the natural logarithm of X. */
126
+ ln(x: EV<number>): Expr<number>;
127
+ /**
128
+ Return the base-10 logarithm for X. Or, for the two-argument version, return the base-B logarithm of X.
129
+ Compatibility note: SQLite works like PostgreSQL in that the log() function computes a base-10 logarithm. Most other SQL database engines compute a natural logarithm for log(). In the two-argument version of log(B,X), the first argument is the base and the second argument is the operand. This is the same as in PostgreSQL and MySQL, but is reversed from SQL Server which uses the second argument as the base and the first argument as the operand.
130
+ */
131
+ log(x: EV<number>, y?: EV<number>): Expr<number>;
132
+ /** Return the logarithm base-2 for the number X. */
133
+ log2(x: EV<number>): Expr<number>;
134
+ /** Return the remainder after dividing X by Y. This is similar to the '%' operator, except that it works for non-numbereger arguments. */
135
+ mod(x: EV<number>, y: EV<number>): Expr<number>;
136
+ /** Return an approximation for π. */
137
+ pi(x: EV<number>): Expr<number>;
138
+ /** Compute X raised to the power Y. */
139
+ pow(x: EV<number>, y: EV<number>): Expr<number>;
140
+ /** Convert X from degrees numbero radians. */
141
+ radians(x: EV<number>): Expr<number>;
142
+ /** Return the sine of X. X is in radians. */
143
+ sin(x: EV<number>): Expr<number>;
144
+ /** Return the hyperbolic sine of X. */
145
+ sinh(x: EV<number>): Expr<number>;
146
+ /** Return the square root of X. NULL is returned if X is negative. */
147
+ sqrt(x: EV<number>): Expr<number>;
148
+ /** Return the tangent of X. X is in radians. */
149
+ tan(x: EV<number>): Expr<number>;
150
+ /** Return the hyperbolic tangent of X. */
151
+ tanh(x: EV<number>): Expr<number>;
152
+ /** Return the representable numbereger in between X and 0 (inclusive) that is furthest away from zero. Or, in other words, return the numbereger part of X, rounding toward zero. The trunc() function is similar to ceiling(X) and floor(X) except that it always rounds toward zero whereas ceiling(X) and floor(X) round up and down, respectively. */
153
+ trunc(x: EV<number>): Expr<number>;
154
+ date(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
155
+ time(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
156
+ datetime(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
157
+ julianday(timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
158
+ strftime(format: EV<string>, timeValue: EV<any>, ...rest: Array<EV<string>>): Expr<string>;
159
+ };
160
+ 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>, highlight: (table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>) => Expr<string>, snippet: (table: Table<any>, index: EV<number>, insertBefore: EV<string>, insertAfter: EV<string>, snip: EV<string>, maxTokens: EV<number>) => Expr<string>, cast: {
161
+ (x: EV<any>, type: 'text'): Expr<string>;
162
+ (x: EV<any>, type: 'real'): Expr<number>;
163
+ (x: EV<any>, type: 'integer'): Expr<number>;
164
+ (x: EV<any>, type: 'numeric'): Expr<number>;
165
+ }, 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>, ...rest: EV<T>[]) => Expr<T>, min: <T>(x: 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>;
@@ -1,25 +1,25 @@
1
- import { Cursor } from '../define/Cursor';
2
- import { Expr } from '../define/Expr';
3
- import { SchemaInstructions } from '../define/Schema';
4
- export declare namespace SqliteSchema {
5
- type Column = {
6
- cid: number;
7
- name: string;
8
- type: string;
9
- notnull: number;
10
- dflt_value: string | null;
11
- pk: number;
12
- };
13
- interface Index {
14
- type: 'index';
15
- name: string;
16
- tbl_name: string;
17
- rootpage: number;
18
- sql: string;
19
- }
20
- function tableData(tableName: Expr<string>): Cursor<Array<SqliteSchema.Column>>;
21
- function indexData(tableName: Expr<string>): Cursor<Array<SqliteSchema.Index>>;
22
- function createInstructions(columnData: Array<Column>, indexData: Array<Index>): SchemaInstructions | undefined;
23
- function columnInstruction(column: Column): [string, string];
24
- function indexInstruction(index: Index): [string, string];
25
- }
1
+ import { Cursor } from '../define/Cursor';
2
+ import { Expr } from '../define/Expr';
3
+ import { SchemaInstructions } from '../define/Schema';
4
+ export declare namespace SqliteSchema {
5
+ type Column = {
6
+ cid: number;
7
+ name: string;
8
+ type: string;
9
+ notnull: number;
10
+ dflt_value: string | null;
11
+ pk: number;
12
+ };
13
+ interface Index {
14
+ type: 'index';
15
+ name: string;
16
+ tbl_name: string;
17
+ rootpage: number;
18
+ sql: string;
19
+ }
20
+ function tableData(tableName: Expr<string>): Cursor<Array<SqliteSchema.Column>>;
21
+ function indexData(tableName: Expr<string>): Cursor<Array<SqliteSchema.Index>>;
22
+ function createInstructions(columnData: Array<Column>, indexData: Array<Index>): SchemaInstructions | undefined;
23
+ function columnInstruction(column: Column): [string, string];
24
+ function indexInstruction(index: Index): [string, string];
25
+ }