| 13 | |
| 14 | // SQLiteWasmDatabase extends BaseServerDatabase for sqlite-wasm |
| 15 | export class SQLiteWasmDatabase extends BaseServerDatabase { |
| 16 | filename?: string |
| 17 | private db: Database // Using any for now to avoid type issues |
| 18 | |
| 19 | constructor(db: Database) { |
| 20 | super() |
| 21 | this.db = db |
| 22 | this.filename = db.filename |
| 23 | } |
| 24 | |
| 25 | get isWalMode() { |
| 26 | return true |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Check if currently inside a transaction. |
| 31 | * Uses PRAGMA transaction_state (SQLite 3.37.0+). |
| 32 | * Returns "idle" | "active" | "conflict" |
| 33 | */ |
| 34 | get inTransaction(): boolean { |
| 35 | try { |
| 36 | const result = this.db.exec({ |
| 37 | sql: "PRAGMA transaction_state", |
| 38 | returnValue: "resultRows", |
| 39 | rowMode: "array", |
| 40 | }) |
| 41 | // result is [["idle"]] or [["active"]] or [["conflict"]] |
| 42 | const state = result?.[0]?.[0] |
| 43 | return state === "active" || state === "conflict" |
| 44 | } catch (e) { |
| 45 | // Fallback: try to detect via autocommit mode |
| 46 | try { |
| 47 | // If we can't get transaction_state, assume not in transaction |
| 48 | return false |
| 49 | } catch { |
| 50 | return false |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | selectObjectsSync(): { [columnName: string]: any }[] { |
| 56 | throw new Error("selectObjectsSync is not implemented") |
| 57 | } |
| 58 | |
| 59 | table() { |
| 60 | throw new Error("table is not implemented") |
| 61 | } |
| 62 | |
| 63 | pages(): Promise<{ [key: string]: any }> { |
| 64 | return Promise.resolve({}) |
| 65 | } |
| 66 | |
| 67 | status(): Promise<{ [key: string]: any }> { |
| 68 | return Promise.resolve({}) |
| 69 | } |
| 70 | |
| 71 | pull(): Promise<{ [key: string]: any }> { |
| 72 | return Promise.resolve({}) |
nothing calls this directly
no outgoing calls
no test coverage detected