@prisma-next/adapter-sqlite 0.12.0-dev.6 → 0.12.0-dev.60
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/{adapter-Cn_t9TdZ.d.mts → adapter-CPydDe3Y.d.mts} +4 -3
- package/dist/adapter-CPydDe3Y.d.mts.map +1 -0
- package/dist/adapter-DY-fQQc9.mjs +764 -0
- package/dist/adapter-DY-fQQc9.mjs.map +1 -0
- package/dist/adapter.d.mts +1 -1
- package/dist/adapter.mjs +1 -1
- package/dist/codec-types.d.mts +1 -1
- package/dist/control.d.mts +56 -7
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +4 -195
- package/dist/control.mjs.map +1 -1
- package/dist/{descriptor-meta-yjlqZvLC.mjs → descriptor-meta-Du5OgSxS.mjs} +1 -1
- package/dist/{descriptor-meta-yjlqZvLC.mjs.map → descriptor-meta-Du5OgSxS.mjs.map} +1 -1
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.mjs +3 -3
- package/dist/{types-bTlW__XL.d.mts → types-rMUNtvF6.d.mts} +1 -1
- package/dist/{types-bTlW__XL.d.mts.map → types-rMUNtvF6.d.mts.map} +1 -1
- package/dist/types.d.mts +2 -2
- package/package.json +24 -24
- package/src/core/adapter.ts +79 -44
- package/src/core/control-adapter.ts +323 -118
- package/src/core/ddl-renderer.ts +67 -0
- package/src/core/ledger-decode.ts +26 -0
- package/src/core/marker-ledger.ts +124 -0
- package/dist/adapter-BOg2xl4V.mjs +0 -348
- package/dist/adapter-BOg2xl4V.mjs.map +0 -1
- package/dist/adapter-Cn_t9TdZ.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-meta-
|
|
1
|
+
{"version":3,"file":"descriptor-meta-Du5OgSxS.mjs","names":[],"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["export const sqliteAdapterDescriptorMeta = {\n kind: 'adapter',\n familyId: 'sql',\n targetId: 'sqlite',\n id: 'sqlite',\n version: '0.0.1',\n capabilities: {\n sql: {\n orderBy: true,\n limit: true,\n lateral: false,\n jsonAgg: true,\n returning: true,\n foreignKeys: true,\n enums: false,\n },\n },\n types: {\n codecTypes: {\n import: {\n package: '@prisma-next/adapter-sqlite/codec-types',\n named: 'CodecTypes',\n alias: 'SqliteTypes',\n },\n },\n },\n} as const;\n"],"mappings":";AAAA,MAAa,8BAA8B;CACzC,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,EACZ,KAAK;EACH,SAAS;EACT,OAAO;EACP,SAAS;EACT,SAAS;EACT,WAAW;EACX,aAAa;EACb,OAAO;CACT,EACF;CACA,OAAO,EACL,YAAY,EACV,QAAQ;EACN,SAAS;EACT,OAAO;EACP,OAAO;CACT,EACF,EACF;AACF"}
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createSqliteAdapter } from "./adapter-
|
|
1
|
+
import { t as createSqliteAdapter } from "./adapter-CPydDe3Y.mjs";
|
|
2
2
|
import { SqlRuntimeAdapterDescriptor } from "@prisma-next/sql-runtime";
|
|
3
3
|
import { RuntimeAdapterInstance } from "@prisma-next/framework-components/execution";
|
|
4
4
|
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as sqliteAdapterDescriptorMeta } from "./descriptor-meta-
|
|
1
|
+
import { n as sqliteRawCodecInferer, t as createSqliteAdapter } from "./adapter-DY-fQQc9.mjs";
|
|
2
|
+
import { t as sqliteAdapterDescriptorMeta } from "./descriptor-meta-Du5OgSxS.mjs";
|
|
3
|
+
import { sqliteCodecRegistry } from "@prisma-next/target-sqlite/codecs";
|
|
3
4
|
import { builtinGeneratorIds } from "@prisma-next/ids";
|
|
4
5
|
import { timestampNowRuntimeGenerator } from "@prisma-next/family-sql/runtime";
|
|
5
6
|
import { generateId } from "@prisma-next/ids/runtime";
|
|
6
|
-
import { sqliteCodecRegistry } from "@prisma-next/target-sqlite/codecs";
|
|
7
7
|
//#region src/core/runtime-adapter.ts
|
|
8
8
|
function createSqliteMutationDefaultGenerators() {
|
|
9
9
|
return [...builtinGeneratorIds.map((id) => ({
|
|
@@ -12,4 +12,4 @@ type SqliteContract = Contract<SqlStorage> & {
|
|
|
12
12
|
type SqliteLoweredStatement = LoweredStatement;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { SqliteContract as n, SqliteLoweredStatement as r, SqliteAdapterOptions as t };
|
|
15
|
-
//# sourceMappingURL=types-
|
|
15
|
+
//# sourceMappingURL=types-rMUNtvF6.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-
|
|
1
|
+
{"version":3,"file":"types-rMUNtvF6.d.mts","names":[],"sources":["../src/core/types.ts"],"mappings":";;;;;UAIiB,oBAAA;EAAA,SACN,SAAS;AAAA;AAAA,KAGR,cAAA,GAAiB,QAAQ,CAAC,UAAA;EAAA,SAAyB,MAAA;AAAA;AAAA,KAEnD,sBAAA,GAAyB,gBAAgB"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as SqliteContract, r as SqliteLoweredStatement } from "./types-
|
|
2
|
-
export {
|
|
1
|
+
import { n as SqliteContract, r as SqliteLoweredStatement } from "./types-rMUNtvF6.mjs";
|
|
2
|
+
export type { SqliteContract, SqliteLoweredStatement };
|
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/adapter-sqlite",
|
|
3
|
-
"version": "0.12.0-dev.
|
|
3
|
+
"version": "0.12.0-dev.60",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/cli": "0.12.0-dev.
|
|
9
|
-
"@prisma-next/contract": "0.12.0-dev.
|
|
10
|
-
"@prisma-next/contract-authoring": "0.12.0-dev.
|
|
11
|
-
"@prisma-next/errors": "0.12.0-dev.
|
|
12
|
-
"@prisma-next/framework-components": "0.12.0-dev.
|
|
13
|
-
"@prisma-next/family-sql": "0.12.0-dev.
|
|
14
|
-
"@prisma-next/ids": "0.12.0-dev.
|
|
15
|
-
"@prisma-next/sql-contract": "0.12.0-dev.
|
|
16
|
-
"@prisma-next/sql-contract-psl": "0.12.0-dev.
|
|
17
|
-
"@prisma-next/sql-contract-ts": "0.12.0-dev.
|
|
18
|
-
"@prisma-next/sql-operations": "0.12.0-dev.
|
|
19
|
-
"@prisma-next/sql-relational-core": "0.12.0-dev.
|
|
20
|
-
"@prisma-next/sql-runtime": "0.12.0-dev.
|
|
21
|
-
"@prisma-next/sql-schema-ir": "0.12.0-dev.
|
|
22
|
-
"@prisma-next/target-sqlite": "0.12.0-dev.
|
|
23
|
-
"@prisma-next/utils": "0.12.0-dev.
|
|
8
|
+
"@prisma-next/cli": "0.12.0-dev.60",
|
|
9
|
+
"@prisma-next/contract": "0.12.0-dev.60",
|
|
10
|
+
"@prisma-next/contract-authoring": "0.12.0-dev.60",
|
|
11
|
+
"@prisma-next/errors": "0.12.0-dev.60",
|
|
12
|
+
"@prisma-next/framework-components": "0.12.0-dev.60",
|
|
13
|
+
"@prisma-next/family-sql": "0.12.0-dev.60",
|
|
14
|
+
"@prisma-next/ids": "0.12.0-dev.60",
|
|
15
|
+
"@prisma-next/sql-contract": "0.12.0-dev.60",
|
|
16
|
+
"@prisma-next/sql-contract-psl": "0.12.0-dev.60",
|
|
17
|
+
"@prisma-next/sql-contract-ts": "0.12.0-dev.60",
|
|
18
|
+
"@prisma-next/sql-operations": "0.12.0-dev.60",
|
|
19
|
+
"@prisma-next/sql-relational-core": "0.12.0-dev.60",
|
|
20
|
+
"@prisma-next/sql-runtime": "0.12.0-dev.60",
|
|
21
|
+
"@prisma-next/sql-schema-ir": "0.12.0-dev.60",
|
|
22
|
+
"@prisma-next/target-sqlite": "0.12.0-dev.60",
|
|
23
|
+
"@prisma-next/utils": "0.12.0-dev.60",
|
|
24
24
|
"arktype": "^2.2.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@prisma-next/driver-sqlite": "0.12.0-dev.
|
|
28
|
-
"@prisma-next/migration-tools": "0.12.0-dev.
|
|
29
|
-
"@prisma-next/test-utils": "0.12.0-dev.
|
|
30
|
-
"@prisma-next/tsconfig": "0.12.0-dev.
|
|
31
|
-
"@prisma-next/tsdown": "0.12.0-dev.
|
|
27
|
+
"@prisma-next/driver-sqlite": "0.12.0-dev.60",
|
|
28
|
+
"@prisma-next/migration-tools": "0.12.0-dev.60",
|
|
29
|
+
"@prisma-next/test-utils": "0.12.0-dev.60",
|
|
30
|
+
"@prisma-next/tsconfig": "0.12.0-dev.60",
|
|
31
|
+
"@prisma-next/tsdown": "0.12.0-dev.60",
|
|
32
32
|
"pathe": "^2.0.3",
|
|
33
|
-
"tsdown": "0.22.
|
|
33
|
+
"tsdown": "0.22.1",
|
|
34
34
|
"typescript": "5.9.3",
|
|
35
|
-
"vitest": "4.1.
|
|
35
|
+
"vitest": "4.1.7"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"typescript": ">=5.9"
|
package/src/core/adapter.ts
CHANGED
|
@@ -19,7 +19,6 @@ import type {
|
|
|
19
19
|
LiteralExpr,
|
|
20
20
|
LoweredParam,
|
|
21
21
|
LowererContext,
|
|
22
|
-
MarkerReadResult,
|
|
23
22
|
NullCheckExpr,
|
|
24
23
|
OperationExpr,
|
|
25
24
|
OrderByItem,
|
|
@@ -29,12 +28,16 @@ import type {
|
|
|
29
28
|
SelectAst,
|
|
30
29
|
SqlQueryable,
|
|
31
30
|
SubqueryExpr,
|
|
31
|
+
TableSource,
|
|
32
32
|
UpdateAst,
|
|
33
33
|
WindowFuncExpr,
|
|
34
34
|
} from '@prisma-next/sql-relational-core/ast';
|
|
35
|
+
import { isDdlNode } from '@prisma-next/sql-relational-core/ast';
|
|
35
36
|
import type { RawCodecInferer } from '@prisma-next/sql-relational-core/expression';
|
|
36
|
-
import {
|
|
37
|
+
import type { SqliteDdlNode } from '@prisma-next/target-sqlite/ddl';
|
|
37
38
|
import { escapeLiteral, quoteIdentifier } from '@prisma-next/target-sqlite/sql-utils';
|
|
39
|
+
import { SqliteControlAdapter } from './control-adapter';
|
|
40
|
+
import { renderLoweredDdl } from './ddl-renderer';
|
|
38
41
|
import type { SqliteAdapterOptions, SqliteContract, SqliteLoweredStatement } from './types';
|
|
39
42
|
|
|
40
43
|
const defaultCapabilities = Object.freeze({
|
|
@@ -55,15 +58,37 @@ class SqliteAdapterImpl implements Adapter<AnyQueryAst, SqliteContract, SqliteLo
|
|
|
55
58
|
readonly profile: AdapterProfile<'sqlite'>;
|
|
56
59
|
|
|
57
60
|
constructor(options?: SqliteAdapterOptions) {
|
|
61
|
+
const controlAdapter = new SqliteControlAdapter();
|
|
58
62
|
this.profile = Object.freeze({
|
|
59
63
|
id: options?.profileId ?? 'sqlite/default@1',
|
|
60
64
|
target: 'sqlite',
|
|
61
65
|
capabilities: defaultCapabilities,
|
|
62
|
-
readMarker: (queryable: SqlQueryable) =>
|
|
66
|
+
readMarker: (queryable: SqlQueryable) =>
|
|
67
|
+
controlAdapter.readMarkerDiscriminated(
|
|
68
|
+
{
|
|
69
|
+
familyId: 'sql',
|
|
70
|
+
targetId: 'sqlite',
|
|
71
|
+
query: async <Row = Record<string, unknown>>(
|
|
72
|
+
sql: string,
|
|
73
|
+
params?: readonly unknown[],
|
|
74
|
+
) => {
|
|
75
|
+
const result = await queryable.query<Row>(sql, params);
|
|
76
|
+
return { rows: [...result.rows] };
|
|
77
|
+
},
|
|
78
|
+
close: async () => {},
|
|
79
|
+
},
|
|
80
|
+
APP_SPACE_ID,
|
|
81
|
+
),
|
|
63
82
|
});
|
|
64
83
|
}
|
|
65
84
|
|
|
66
|
-
lower(
|
|
85
|
+
lower(
|
|
86
|
+
ast: AnyQueryAst | SqliteDdlNode,
|
|
87
|
+
context: LowererContext<SqliteContract>,
|
|
88
|
+
): SqliteLoweredStatement {
|
|
89
|
+
if (isDdlNode(ast)) {
|
|
90
|
+
return renderLoweredDdl(ast);
|
|
91
|
+
}
|
|
67
92
|
return renderLoweredSql(ast, context.contract);
|
|
68
93
|
}
|
|
69
94
|
}
|
|
@@ -124,7 +149,7 @@ export function renderLoweredSql(
|
|
|
124
149
|
sql = renderUpdate(node, contract);
|
|
125
150
|
break;
|
|
126
151
|
case 'delete':
|
|
127
|
-
sql = renderDelete(node);
|
|
152
|
+
sql = renderDelete(node, contract);
|
|
128
153
|
break;
|
|
129
154
|
default:
|
|
130
155
|
throw new Error(`Unsupported AST node kind: ${(node as { kind: string }).kind}`);
|
|
@@ -143,7 +168,7 @@ function renderLimitOffset(
|
|
|
143
168
|
return `${keyword} ${renderExpr(value, contract)}`;
|
|
144
169
|
}
|
|
145
170
|
|
|
146
|
-
function renderSelect(ast: SelectAst, contract
|
|
171
|
+
function renderSelect(ast: SelectAst, contract: SqliteContract): string {
|
|
147
172
|
const distinctPrefix = ast.distinct ? 'DISTINCT ' : '';
|
|
148
173
|
const selectClause = `SELECT ${distinctPrefix}${renderProjection(ast.projection, contract)}`;
|
|
149
174
|
const fromClause = `FROM ${renderSource(ast.from, contract)}`;
|
|
@@ -196,16 +221,41 @@ function renderProjection(
|
|
|
196
221
|
.join(', ');
|
|
197
222
|
}
|
|
198
223
|
|
|
199
|
-
function
|
|
224
|
+
function qualifyTableFromNamespaceCoordinate(
|
|
225
|
+
table: Pick<TableSource, 'name' | 'namespaceId'>,
|
|
226
|
+
contract: SqliteContract,
|
|
227
|
+
): string {
|
|
228
|
+
if (table.namespaceId === undefined) {
|
|
229
|
+
return quoteIdentifier(table.name);
|
|
230
|
+
}
|
|
231
|
+
const namespace = contract.storage.namespaces[table.namespaceId];
|
|
232
|
+
if (namespace === undefined) {
|
|
233
|
+
throw new Error(
|
|
234
|
+
`Table "${table.name}" references namespace "${table.namespaceId}" which is not present on the contract`,
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
const qualifyTable = namespace.qualifyTable;
|
|
238
|
+
if (qualifyTable === undefined) {
|
|
239
|
+
throw new Error(
|
|
240
|
+
`Table "${table.name}" references namespace "${table.namespaceId}" which is not materialised for SQL rendering on the contract`,
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
return qualifyTable.call(namespace, table.name);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function renderTableSource(source: TableSource, contract: SqliteContract): string {
|
|
247
|
+
const qualified = qualifyTableFromNamespaceCoordinate(source, contract);
|
|
248
|
+
if (!source.alias) {
|
|
249
|
+
return qualified;
|
|
250
|
+
}
|
|
251
|
+
return `${qualified} AS ${quoteIdentifier(source.alias)}`;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function renderSource(source: AnyFromSource, contract: SqliteContract): string {
|
|
200
255
|
const node = source;
|
|
201
256
|
switch (node.kind) {
|
|
202
|
-
case 'table-source':
|
|
203
|
-
|
|
204
|
-
if (!node.alias) {
|
|
205
|
-
return table;
|
|
206
|
-
}
|
|
207
|
-
return `${table} AS ${quoteIdentifier(node.alias)}`;
|
|
208
|
-
}
|
|
257
|
+
case 'table-source':
|
|
258
|
+
return renderTableSource(node, contract);
|
|
209
259
|
case 'derived-table-source':
|
|
210
260
|
return `(${renderSelect(node.query, contract)}) AS ${quoteIdentifier(node.alias)}`;
|
|
211
261
|
default:
|
|
@@ -245,6 +295,9 @@ function renderExpr(expr: AnyExpression, contract?: SqliteContract): string {
|
|
|
245
295
|
}
|
|
246
296
|
return `(${node.exprs.map((part) => renderExpr(part, contract)).join(' OR ')})`;
|
|
247
297
|
case 'exists': {
|
|
298
|
+
if (contract === undefined) {
|
|
299
|
+
throw new Error('EXISTS subquery rendering requires a Sqlite contract');
|
|
300
|
+
}
|
|
248
301
|
const notKeyword = node.notExists ? 'NOT ' : '';
|
|
249
302
|
const subquery = renderSelect(node.subquery, contract);
|
|
250
303
|
return `${notKeyword}EXISTS (${subquery})`;
|
|
@@ -321,6 +374,9 @@ function renderSubqueryExpr(expr: SubqueryExpr, contract?: SqliteContract): stri
|
|
|
321
374
|
if (expr.query.projection.length !== 1) {
|
|
322
375
|
throw new Error('Subquery expressions must project exactly one column');
|
|
323
376
|
}
|
|
377
|
+
if (contract === undefined) {
|
|
378
|
+
throw new Error('Subquery expression rendering requires a Sqlite contract');
|
|
379
|
+
}
|
|
324
380
|
return `(${renderSelect(expr.query, contract)})`;
|
|
325
381
|
}
|
|
326
382
|
|
|
@@ -451,6 +507,9 @@ function renderJsonArrayAggExpr(expr: JsonArrayAggExpr, contract?: SqliteContrac
|
|
|
451
507
|
}
|
|
452
508
|
|
|
453
509
|
function renderJoin(join: JoinAst, contract?: SqliteContract): string {
|
|
510
|
+
if (contract === undefined) {
|
|
511
|
+
throw new Error('JOIN rendering requires a Sqlite contract');
|
|
512
|
+
}
|
|
454
513
|
const joinType = join.joinType.toUpperCase();
|
|
455
514
|
const source = renderSource(join.source, contract);
|
|
456
515
|
const onClause = renderJoinOn(join.on, contract);
|
|
@@ -471,6 +530,8 @@ function renderInsertValue(value: InsertValue): string {
|
|
|
471
530
|
return '?';
|
|
472
531
|
case 'column-ref':
|
|
473
532
|
return renderColumn(value);
|
|
533
|
+
case 'raw-expr':
|
|
534
|
+
return renderExpr(value);
|
|
474
535
|
case 'default-value':
|
|
475
536
|
throw new Error('SQLite does not support DEFAULT as a value in INSERT ... VALUES');
|
|
476
537
|
default:
|
|
@@ -479,7 +540,7 @@ function renderInsertValue(value: InsertValue): string {
|
|
|
479
540
|
}
|
|
480
541
|
|
|
481
542
|
function renderInsert(ast: InsertAst, contract: SqliteContract): string {
|
|
482
|
-
const table =
|
|
543
|
+
const table = qualifyTableFromNamespaceCoordinate(ast.table, contract);
|
|
483
544
|
const rows = ast.rows;
|
|
484
545
|
if (rows.length === 0) {
|
|
485
546
|
throw new Error('INSERT requires at least one row');
|
|
@@ -538,7 +599,7 @@ function renderInsert(ast: InsertAst, contract: SqliteContract): string {
|
|
|
538
599
|
}
|
|
539
600
|
|
|
540
601
|
function renderUpdate(ast: UpdateAst, contract: SqliteContract): string {
|
|
541
|
-
const table =
|
|
602
|
+
const table = qualifyTableFromNamespaceCoordinate(ast.table, contract);
|
|
542
603
|
const setClauses = Object.entries(ast.set).map(([col, val]) => {
|
|
543
604
|
return `${quoteIdentifier(col)} = ${renderExpr(val, contract)}`;
|
|
544
605
|
});
|
|
@@ -549,8 +610,8 @@ function renderUpdate(ast: UpdateAst, contract: SqliteContract): string {
|
|
|
549
610
|
return `UPDATE ${table} SET ${setClauses.join(', ')}${whereClause}${returningClause}`;
|
|
550
611
|
}
|
|
551
612
|
|
|
552
|
-
function renderDelete(ast: DeleteAst): string {
|
|
553
|
-
const table =
|
|
613
|
+
function renderDelete(ast: DeleteAst, contract: SqliteContract): string {
|
|
614
|
+
const table = qualifyTableFromNamespaceCoordinate(ast.table, contract);
|
|
554
615
|
const whereClause = ast.where ? ` WHERE ${renderExpr(ast.where)}` : '';
|
|
555
616
|
const returningClause = renderReturning(ast.returning);
|
|
556
617
|
|
|
@@ -574,32 +635,6 @@ function renderReturning(returning: ReadonlyArray<ProjectionItem> | undefined):
|
|
|
574
635
|
.join(', ')}`;
|
|
575
636
|
}
|
|
576
637
|
|
|
577
|
-
async function readSqliteMarker(queryable: SqlQueryable): Promise<MarkerReadResult> {
|
|
578
|
-
const exists = await queryable.query(
|
|
579
|
-
"select 1 from sqlite_master where type = 'table' and name = ?",
|
|
580
|
-
['_prisma_marker'],
|
|
581
|
-
);
|
|
582
|
-
if (exists.rows.length === 0) {
|
|
583
|
-
return { kind: 'no-table' };
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
const result = await queryable.query(
|
|
587
|
-
'select core_hash, profile_hash, contract_json, canonical_version, updated_at, app_tag, meta, invariants from _prisma_marker where space = ?',
|
|
588
|
-
[APP_SPACE_ID],
|
|
589
|
-
);
|
|
590
|
-
const row = result.rows[0];
|
|
591
|
-
if (!row) {
|
|
592
|
-
return { kind: 'absent' };
|
|
593
|
-
}
|
|
594
|
-
// SQLite stores arrays as JSON-encoded TEXT (no native array type), so the driver returns `invariants` as a string. Decode before delegating to the shared row schema, which expects `string[]`.
|
|
595
|
-
const raw = row as Record<string, unknown>;
|
|
596
|
-
const invariants =
|
|
597
|
-
typeof raw['invariants'] === 'string'
|
|
598
|
-
? (JSON.parse(raw['invariants']) as unknown)
|
|
599
|
-
: raw['invariants'];
|
|
600
|
-
return { kind: 'present', record: parseContractMarkerRow({ ...raw, invariants }) };
|
|
601
|
-
}
|
|
602
|
-
|
|
603
638
|
export function createSqliteAdapter(options?: SqliteAdapterOptions) {
|
|
604
639
|
return Object.freeze(new SqliteAdapterImpl(options));
|
|
605
640
|
}
|