@remix-run/data-table-sqlite 0.4.0 → 0.4.1
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/lib/adapter.d.ts +2 -2
- package/dist/lib/adapter.d.ts.map +1 -1
- package/dist/lib/adapter.js +8 -4
- package/package.json +5 -5
- package/src/lib/adapter.ts +11 -6
package/dist/lib/adapter.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { DataManipulationRequest, DataMigrationRequest, DataMigrationResult
|
|
|
3
3
|
* Synchronous SQLite database client accepted by the sqlite adapter.
|
|
4
4
|
*
|
|
5
5
|
* This matches the shared surface of Node's `node:sqlite` `DatabaseSync`, Bun's `bun:sqlite`
|
|
6
|
-
* `Database`, and
|
|
6
|
+
* `Database`, and compatible synchronous SQLite clients.
|
|
7
7
|
*/
|
|
8
8
|
export interface SqliteDatabase {
|
|
9
9
|
prepare(sql: string): SqliteStatement;
|
|
@@ -24,7 +24,7 @@ export interface SqliteStatement {
|
|
|
24
24
|
* SQLite write execution metadata.
|
|
25
25
|
*/
|
|
26
26
|
export interface SqliteRunResult {
|
|
27
|
-
changes: number;
|
|
27
|
+
changes: number | bigint;
|
|
28
28
|
lastInsertRowid: unknown;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/lib/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,yBAAyB,EACzB,eAAe,EAEf,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAU9B;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAA;IACrC,IAAI,CAAC,GAAG,EAAE,MAA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AAI,CAAC,CAG1E;IAED;;;;;OAKG;IACG,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9E;IAED;;;;;OAKG;IACG,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG3E;CAOF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,cAAc,GAAG,qBAAqB,CAE3F"}
|
package/dist/lib/adapter.js
CHANGED
|
@@ -53,8 +53,9 @@ export class SqliteDatabaseAdapter {
|
|
|
53
53
|
}
|
|
54
54
|
let statement = this.compileSql(request.operation)[0];
|
|
55
55
|
let prepared = this.#database.prepare(statement.text);
|
|
56
|
+
let values = normalizeStatementValues(statement.values);
|
|
56
57
|
if (shouldReadStatement(request.operation, prepared)) {
|
|
57
|
-
let rows = normalizeRows(prepared.all(...
|
|
58
|
+
let rows = normalizeRows(prepared.all(...values));
|
|
58
59
|
if (request.operation.kind === 'count' || request.operation.kind === 'exists') {
|
|
59
60
|
rows = normalizeCountRows(rows);
|
|
60
61
|
}
|
|
@@ -64,7 +65,7 @@ export class SqliteDatabaseAdapter {
|
|
|
64
65
|
insertId: normalizeInsertIdForReader(request.operation.kind, request.operation, rows),
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
|
-
let result = prepared.run(...
|
|
68
|
+
let result = prepared.run(...values);
|
|
68
69
|
return {
|
|
69
70
|
affectedRows: normalizeAffectedRowsForRun(request.operation.kind, result),
|
|
70
71
|
insertId: normalizeInsertIdForRun(request.operation.kind, request.operation, result),
|
|
@@ -79,7 +80,7 @@ export class SqliteDatabaseAdapter {
|
|
|
79
80
|
let statements = this.compileSql(request.operation);
|
|
80
81
|
for (let statement of statements) {
|
|
81
82
|
let prepared = this.#database.prepare(statement.text);
|
|
82
|
-
prepared.run(...statement.values);
|
|
83
|
+
prepared.run(...normalizeStatementValues(statement.values));
|
|
83
84
|
}
|
|
84
85
|
return {
|
|
85
86
|
affectedOperations: statements.length,
|
|
@@ -215,6 +216,9 @@ function normalizeRows(rows) {
|
|
|
215
216
|
return { ...row };
|
|
216
217
|
});
|
|
217
218
|
}
|
|
219
|
+
function normalizeStatementValues(values) {
|
|
220
|
+
return values.map((value) => (value === undefined ? null : value));
|
|
221
|
+
}
|
|
218
222
|
function normalizeCountRows(rows) {
|
|
219
223
|
return rows.map((row) => {
|
|
220
224
|
let count = row.count;
|
|
@@ -258,7 +262,7 @@ function normalizeAffectedRowsForRun(kind, result) {
|
|
|
258
262
|
if (kind === 'select' || kind === 'count' || kind === 'exists') {
|
|
259
263
|
return undefined;
|
|
260
264
|
}
|
|
261
|
-
return result.changes;
|
|
265
|
+
return Number(result.changes);
|
|
262
266
|
}
|
|
263
267
|
function normalizeInsertIdForRun(kind, operation, result) {
|
|
264
268
|
if (!isInsertOperationKind(kind) || !isInsertOperation(operation)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remix-run/data-table-sqlite",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "SQLite adapter for remix/data-table",
|
|
5
5
|
"author": "Michael Jackson <mjijackson@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "^24.6.0",
|
|
31
31
|
"@typescript/native-preview": "7.0.0-dev.20251125.1",
|
|
32
|
-
"@remix-run/assert": "0.
|
|
33
|
-
"@remix-run/
|
|
34
|
-
"@remix-run/
|
|
32
|
+
"@remix-run/assert": "0.2.0",
|
|
33
|
+
"@remix-run/test": "0.3.0",
|
|
34
|
+
"@remix-run/data-table": "0.2.1"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@remix-run/data-table": "^0.2.
|
|
37
|
+
"@remix-run/data-table": "^0.2.1"
|
|
38
38
|
},
|
|
39
39
|
"keywords": [
|
|
40
40
|
"remix",
|
package/src/lib/adapter.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { compileSqliteOperation } from './sql-compiler.ts'
|
|
|
25
25
|
* Synchronous SQLite database client accepted by the sqlite adapter.
|
|
26
26
|
*
|
|
27
27
|
* This matches the shared surface of Node's `node:sqlite` `DatabaseSync`, Bun's `bun:sqlite`
|
|
28
|
-
* `Database`, and
|
|
28
|
+
* `Database`, and compatible synchronous SQLite clients.
|
|
29
29
|
*/
|
|
30
30
|
export interface SqliteDatabase {
|
|
31
31
|
prepare(sql: string): SqliteStatement
|
|
@@ -48,7 +48,7 @@ export interface SqliteStatement {
|
|
|
48
48
|
* SQLite write execution metadata.
|
|
49
49
|
*/
|
|
50
50
|
export interface SqliteRunResult {
|
|
51
|
-
changes: number
|
|
51
|
+
changes: number | bigint
|
|
52
52
|
lastInsertRowid: unknown
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -111,9 +111,10 @@ export class SqliteDatabaseAdapter implements DatabaseAdapter {
|
|
|
111
111
|
|
|
112
112
|
let statement = this.compileSql(request.operation)[0]
|
|
113
113
|
let prepared = this.#database.prepare(statement.text)
|
|
114
|
+
let values = normalizeStatementValues(statement.values)
|
|
114
115
|
|
|
115
116
|
if (shouldReadStatement(request.operation, prepared)) {
|
|
116
|
-
let rows = normalizeRows(prepared.all(...
|
|
117
|
+
let rows = normalizeRows(prepared.all(...values))
|
|
117
118
|
|
|
118
119
|
if (request.operation.kind === 'count' || request.operation.kind === 'exists') {
|
|
119
120
|
rows = normalizeCountRows(rows)
|
|
@@ -126,7 +127,7 @@ export class SqliteDatabaseAdapter implements DatabaseAdapter {
|
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
let result = prepared.run(...
|
|
130
|
+
let result = prepared.run(...values)
|
|
130
131
|
|
|
131
132
|
return {
|
|
132
133
|
affectedRows: normalizeAffectedRowsForRun(request.operation.kind, result),
|
|
@@ -144,7 +145,7 @@ export class SqliteDatabaseAdapter implements DatabaseAdapter {
|
|
|
144
145
|
|
|
145
146
|
for (let statement of statements) {
|
|
146
147
|
let prepared = this.#database.prepare(statement.text)
|
|
147
|
-
prepared.run(...statement.values)
|
|
148
|
+
prepared.run(...normalizeStatementValues(statement.values))
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
return {
|
|
@@ -308,6 +309,10 @@ function normalizeRows(rows: unknown[]): Record<string, unknown>[] {
|
|
|
308
309
|
})
|
|
309
310
|
}
|
|
310
311
|
|
|
312
|
+
function normalizeStatementValues(values: unknown[]): unknown[] {
|
|
313
|
+
return values.map((value) => (value === undefined ? null : value))
|
|
314
|
+
}
|
|
315
|
+
|
|
311
316
|
function normalizeCountRows(rows: Record<string, unknown>[]): Record<string, unknown>[] {
|
|
312
317
|
return rows.map((row) => {
|
|
313
318
|
let count = row.count
|
|
@@ -374,7 +379,7 @@ function normalizeAffectedRowsForRun(
|
|
|
374
379
|
return undefined
|
|
375
380
|
}
|
|
376
381
|
|
|
377
|
-
return result.changes
|
|
382
|
+
return Number(result.changes)
|
|
378
383
|
}
|
|
379
384
|
|
|
380
385
|
function normalizeInsertIdForRun(
|