@crvouga/sqlite-mem 1.1.2 → 1.3.0
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/AGENTS.md +4 -1
- package/COMPATIBILITY-AUDIT.md +29 -15
- package/COMPATIBILITY.md +16 -8
- package/README.md +26 -15
- package/compat/coverage.json +779 -729
- package/compat/divergences.json +124 -0
- package/compat/requirements.json +43 -43
- package/compat/scenario-types.ts +63 -0
- package/compat/scenarios.ts +851 -0
- package/compat/smoke-baseline.json +15 -0
- package/dist/api/database.d.ts +12 -3
- package/dist/api/statement.d.ts +2 -1
- package/dist/ast/nodes.d.ts +3 -0
- package/dist/executor/env.d.ts +3 -1
- package/dist/executor/select.d.ts +2 -1
- package/dist/executor/triggers.d.ts +2 -2
- package/dist/expressions/context.d.ts +3 -1
- package/dist/expressions/like.d.ts +3 -2
- package/dist/functions/registry.d.ts +2 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +790 -211
- package/dist/index.js.map +4 -4
- package/dist/parser/index.d.ts +7 -1
- package/dist/parser/parser.d.ts +14 -4
- package/dist/runtime/clock.d.ts +4 -2
- package/dist/runtime/index.d.ts +3 -3
- package/dist/runtime/options.d.ts +11 -3
- package/dist/runtime/prng.d.ts +11 -0
- package/dist/schema/master-sql.d.ts +10 -0
- package/dist/storage/database-state.d.ts +2 -0
- package/dist/storage/table.d.ts +2 -0
- package/dist/types/value.d.ts +5 -0
- package/dist/unstable.d.ts +3 -3
- package/dist/unstable.js +263 -72
- package/dist/unstable.js.map +3 -3
- package/dist/vtable/fts/table.d.ts +2 -3
- package/package.json +10 -3
package/dist/api/database.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DatabaseOptions } from "../runtime/index.js";
|
|
1
|
+
import { type DatabaseOptions, type RandomMode } from "../runtime/index.js";
|
|
2
2
|
import type { BindValue, QueryRow } from "../types/value.js";
|
|
3
3
|
import { Statement } from "./statement.js";
|
|
4
4
|
/**
|
|
@@ -6,7 +6,8 @@ import { Statement } from "./statement.js";
|
|
|
6
6
|
*
|
|
7
7
|
* Deterministic by default: `random()` / `randomblob()` use a seeded PRNG
|
|
8
8
|
* (`seed` defaults to `1`) and `date('now')` / friends use a fixed clock
|
|
9
|
-
* (`2000-01-01T00:00:00.000Z`).
|
|
9
|
+
* (`2000-01-01T00:00:00.000Z`). Pass `{ random: "os" }` and `{ now: "system" }`
|
|
10
|
+
* for SQLite-like CSPRNG and wall-clock `'now'`. There is no filesystem or WASM.
|
|
10
11
|
*
|
|
11
12
|
* @example
|
|
12
13
|
* ```ts
|
|
@@ -19,8 +20,10 @@ import { Statement } from "./statement.js";
|
|
|
19
20
|
* ```
|
|
20
21
|
*/
|
|
21
22
|
export declare class Database {
|
|
22
|
-
/** Seed used to construct the PRNG. */
|
|
23
|
+
/** Seed used to construct the PRNG. Ignored when {@link randomMode} is `"os"`. */
|
|
23
24
|
readonly seed: number | bigint;
|
|
25
|
+
/** Entropy mode for `random()` / `randomblob()`. */
|
|
26
|
+
readonly randomMode: RandomMode;
|
|
24
27
|
private closed;
|
|
25
28
|
private transactionSequence;
|
|
26
29
|
/** Depth of active {@link transaction} callbacks (not SQL BEGIN). */
|
|
@@ -106,6 +109,12 @@ export declare class Database {
|
|
|
106
109
|
* @throws {SqliteError} If the database is closed.
|
|
107
110
|
*/
|
|
108
111
|
get lastInsertRowid(): number | bigint;
|
|
112
|
+
/**
|
|
113
|
+
* Cumulative rows changed by INSERT / UPDATE / DELETE (SQLite `total_changes()`).
|
|
114
|
+
*
|
|
115
|
+
* @throws {SqliteError} If the database is closed.
|
|
116
|
+
*/
|
|
117
|
+
get totalChanges(): number;
|
|
109
118
|
private prepareSingle;
|
|
110
119
|
}
|
|
111
120
|
export type { DatabaseOptions };
|
package/dist/api/statement.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ResultSet } from "../executor/result.js";
|
|
2
2
|
import type { BindValue, QueryRow } from "../types/value.js";
|
|
3
3
|
/** Mutation counters returned by {@link Statement.run}. */
|
|
4
4
|
export interface RunResult {
|
|
@@ -31,6 +31,7 @@ export declare class Statement {
|
|
|
31
31
|
private namedPlan;
|
|
32
32
|
private env;
|
|
33
33
|
private statements;
|
|
34
|
+
private statementSqls;
|
|
34
35
|
private schemaVersion;
|
|
35
36
|
private constructor();
|
|
36
37
|
/**
|
package/dist/ast/nodes.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export interface FunctionExpr {
|
|
|
62
62
|
name: string;
|
|
63
63
|
distinct: boolean;
|
|
64
64
|
args: Expr[] | "*";
|
|
65
|
+
orderBy: OrderByItem[];
|
|
65
66
|
filter: Expr | null;
|
|
66
67
|
}
|
|
67
68
|
export interface AggregateExpr {
|
|
@@ -69,6 +70,7 @@ export interface AggregateExpr {
|
|
|
69
70
|
name: string;
|
|
70
71
|
distinct: boolean;
|
|
71
72
|
args: Expr[] | "*";
|
|
73
|
+
orderBy: OrderByItem[];
|
|
72
74
|
filter: Expr | null;
|
|
73
75
|
}
|
|
74
76
|
export interface WindowExpr {
|
|
@@ -192,6 +194,7 @@ export interface WithClause {
|
|
|
192
194
|
export interface Cte {
|
|
193
195
|
name: string;
|
|
194
196
|
columns: string[] | null;
|
|
197
|
+
materialized: "materialized" | "not_materialized" | null;
|
|
195
198
|
select: SelectStmt;
|
|
196
199
|
}
|
|
197
200
|
export type ResultColumn = {
|
package/dist/executor/env.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { type FunctionRegistry } from "../functions/registry.js";
|
|
|
4
4
|
import type { DatabaseState } from "../storage/database-state.js";
|
|
5
5
|
import type { Rowid } from "../storage/row.js";
|
|
6
6
|
import type { TransactionManager } from "../transactions/manager.js";
|
|
7
|
-
import type { ResultSet } from "./result.js";
|
|
8
7
|
import { type Affinity, type SqlValue } from "../types/value.js";
|
|
8
|
+
import type { ResultSet } from "./result.js";
|
|
9
9
|
export interface Cell {
|
|
10
10
|
table: string | null;
|
|
11
11
|
tableLower?: string | null;
|
|
@@ -51,6 +51,8 @@ export declare class ExecutionEnv {
|
|
|
51
51
|
maxRows: number;
|
|
52
52
|
includeNamedRows: boolean;
|
|
53
53
|
includeValues: boolean;
|
|
54
|
+
/** Source text of the statement currently executing (for sqlite_master.sql). */
|
|
55
|
+
statementSql: string | null;
|
|
54
56
|
constructor(state: DatabaseState, transactions: TransactionManager, params?: readonly unknown[], functions?: FunctionRegistry, hooks?: ExecutionHooks);
|
|
55
57
|
reset(params: readonly unknown[]): void;
|
|
56
58
|
getBoundParameter(name: string | number): SqlValue;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { FromItem, SelectStmt } from "../ast/nodes.js";
|
|
1
|
+
import type { FromItem, SelectStmt, WithClause } from "../ast/nodes.js";
|
|
2
2
|
import type { EvalContext } from "../expressions/context.js";
|
|
3
3
|
import type { ExecutionEnv, ScopeRow } from "./env.js";
|
|
4
4
|
import { type ResultSet } from "./result.js";
|
|
5
5
|
export declare function executeSelect(stmt: SelectStmt, env: ExecutionEnv, parent?: EvalContext): ResultSet;
|
|
6
|
+
export declare function executeWith(withClause: WithClause, env: ExecutionEnv, parent?: EvalContext): void;
|
|
6
7
|
export declare function scanFrom(item: FromItem, env: ExecutionEnv, parent?: EvalContext): ScopeRow[];
|
|
@@ -7,5 +7,5 @@ import { type ResultSet } from "./result.js";
|
|
|
7
7
|
export declare function executeCreateTrigger(stmt: CreateTriggerStmt, env: ExecutionEnv): ResultSet;
|
|
8
8
|
export declare function executeDropTrigger(stmt: DropTriggerStmt, env: ExecutionEnv): ResultSet;
|
|
9
9
|
export declare function fireInsertTriggers(timing: "BEFORE" | "AFTER" | "INSTEAD", table: Table, values: Map<string, SqlValue>, oldRow: Row | null, env: ExecutionEnv): "ok" | "ignore";
|
|
10
|
-
export declare function fireUpdateTriggers(timing: "BEFORE" | "AFTER", table: Table, oldRow: Row, newValues: Map<string, SqlValue>, updatedColumns: Set<string>, env: ExecutionEnv): "ok" | "ignore";
|
|
11
|
-
export declare function fireDeleteTriggers(timing: "BEFORE" | "AFTER", table: Table, oldRow: Row, env: ExecutionEnv): "ok" | "ignore";
|
|
10
|
+
export declare function fireUpdateTriggers(timing: "BEFORE" | "AFTER" | "INSTEAD", table: Table, oldRow: Row, newValues: Map<string, SqlValue>, updatedColumns: Set<string>, env: ExecutionEnv): "ok" | "ignore";
|
|
11
|
+
export declare function fireDeleteTriggers(timing: "BEFORE" | "AFTER" | "INSTEAD", table: Table, oldRow: Row, env: ExecutionEnv): "ok" | "ignore";
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { SelectStmt } from "../ast/nodes.js";
|
|
2
2
|
import type { FunctionContext, FunctionRegistry } from "../functions/registry.js";
|
|
3
|
-
import type { SqlValue, StorageClass } from "../types/value.js";
|
|
3
|
+
import type { Affinity, SqlValue, StorageClass } from "../types/value.js";
|
|
4
4
|
import type { FtsMatchCursor } from "../vtable/fts5.js";
|
|
5
5
|
/** Column / parameter / function resolution used by {@link evalExpr}. */
|
|
6
6
|
export interface EvalContext {
|
|
7
7
|
resolveColumn(table: string | null, name: string): SqlValue;
|
|
8
8
|
resolveStorageClass?(table: string | null, name: string): StorageClass;
|
|
9
|
+
/** Declared column affinity when available (for comparisons). */
|
|
10
|
+
resolveAffinity?(table: string | null, name: string): Affinity | null;
|
|
9
11
|
/** Declared column collation when available (for inheritance). */
|
|
10
12
|
resolveCollation?(table: string | null, name: string): string | null;
|
|
11
13
|
getParameter(name: string | number): SqlValue;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SQLite LIKE matching. ASCII letters are case-insensitive
|
|
2
|
+
* SQLite LIKE matching. ASCII letters are case-insensitive unless `caseSensitive`.
|
|
3
3
|
*
|
|
4
4
|
* @param text - Value to test.
|
|
5
5
|
* @param pattern - Pattern with `%` / `_` wildcards.
|
|
6
6
|
* @param escape - Optional single-character ESCAPE (or `null`).
|
|
7
|
+
* @param caseSensitive - When true, match like GLOB (SQLite `PRAGMA case_sensitive_like=ON`).
|
|
7
8
|
*/
|
|
8
|
-
export declare function likeMatch(text: string, pattern: string, escape?: string | null): boolean;
|
|
9
|
+
export declare function likeMatch(text: string, pattern: string, escape?: string | null, caseSensitive?: boolean): boolean;
|
|
9
10
|
/**
|
|
10
11
|
* SQLite GLOB matching. GLOB is case-sensitive and uses Unix `*` / `?` wildcards.
|
|
11
12
|
*
|
|
@@ -12,6 +12,8 @@ export interface FunctionContext {
|
|
|
12
12
|
randomU64?: () => bigint;
|
|
13
13
|
/** Active FTS MATCH cursor when evaluating projections with MATCH in WHERE. */
|
|
14
14
|
ftsMatch?: import("../vtable/fts5.js").FtsMatchCursor | null;
|
|
15
|
+
/** SQLite `PRAGMA case_sensitive_like` for LIKE / like(). */
|
|
16
|
+
caseSensitiveLike?: boolean;
|
|
15
17
|
/** Current rowid for FTS aux defaults when MATCH is absent. */
|
|
16
18
|
ftsRowid?: import("../storage/row.js").Rowid;
|
|
17
19
|
/** Source FTS table name for the current scan row. */
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Pure TypeScript in-memory SQLite. Import {@link Database} to get started.
|
|
4
4
|
*
|
|
5
5
|
* Deterministic by default (`random()` seed `1`, `'now'` = `2000-01-01T00:00:00.000Z`).
|
|
6
|
+
* Pass `{ random: "os" }` / `{ now: "system" }` for SQLite-like entropy and wall clock.
|
|
6
7
|
* Zero WASM, native bindings, or filesystem.
|
|
7
8
|
*
|
|
8
9
|
* Advanced / internal helpers live under `@crvouga/sqlite-mem/unstable` and are
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
* @module
|
|
22
23
|
*/
|
|
23
24
|
export { Database, type DatabaseOptions } from "./api/database.js";
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
25
|
+
export { type RunResult, Statement } from "./api/statement.js";
|
|
26
|
+
export { type ErrorCategory, SqliteError } from "./errors/index.js";
|
|
26
27
|
export type { ResultSet } from "./executor/result.js";
|
|
27
28
|
export type { BindValue, QueryRow, QueryValue } from "./types/value.js";
|