@sproutboat/wire 0.14.4 → 0.14.6
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/CHANGELOG.md +31 -0
- package/package.json +2 -2
- package/src/d1.ts +17 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @sproutboat/wire
|
|
2
2
|
|
|
3
|
+
## 0.14.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [ef40955]
|
|
8
|
+
- Updated dependencies [95f6bd7]
|
|
9
|
+
- @sproutboat/runtime@0.25.0
|
|
10
|
+
|
|
11
|
+
## 0.14.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 9a5363e: D1 matches workerd from compatibility date `2026-10-24`:
|
|
16
|
+
|
|
17
|
+
- `all()`, `run()`, `first()`, `raw()`, `batch()` and `exec()` return Promises, and errors reject them. `bind()` stays synchronous and still throws `D1_TYPE_ERROR` at once.
|
|
18
|
+
- `meta` has D1's keys: `served_by`, `duration`, `changes`, `last_row_id`, `changed_db`, `size_after` (always 0 here), `rows_read` and `rows_written`.
|
|
19
|
+
- `raw({ columnNames: true })` puts the column names first, and keeps duplicate names.
|
|
20
|
+
- `first("name")` throws `D1_COLUMN_NOTFOUND` for a column the result doesn't have.
|
|
21
|
+
- Empty SQL and an empty `batch([])` throw `D1_ERROR: No SQL statements detected.`
|
|
22
|
+
- `BEGIN`, `COMMIT`, `ROLLBACK`, `SAVEPOINT` and `RELEASE` are refused, as in D1. A batch is already one transaction.
|
|
23
|
+
- `exec()` runs line by line, all or nothing, and returns the number of lines. A failing line throws `D1_EXEC_ERROR: Error in line N: ...`.
|
|
24
|
+
- `withSession()` returns a session with `prepare`, `batch` and `getBookmark()`, which returns `null`. `dump()` rejects; use `backup()` instead.
|
|
25
|
+
|
|
26
|
+
Apps with an earlier `compatibility_date` keep the synchronous API unchanged. To opt in, move the date to `2026-10-24` or later and rebuild. `await` code needs no other change, but code that reads results without `await` does.
|
|
27
|
+
|
|
28
|
+
Not yet like D1: `rows_read` counts the rows returned, not the rows scanned, and pragmas are not limited to D1's allow-list.
|
|
29
|
+
|
|
30
|
+
With LTX capture on (from `2026-10-22`), a capture failure during a D1 call now reports `SQLITE_IOERR` with a message saying the write is not durable in the replication log, instead of SQLite's "not an error". Writes stay refused until restart.
|
|
31
|
+
- Updated dependencies [9a5363e]
|
|
32
|
+
- @sproutboat/runtime@0.24.0
|
|
33
|
+
|
|
3
34
|
## 0.14.4
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sproutboat/wire",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@sproutboat/assets": "^0.3.0",
|
|
26
|
-
"@sproutboat/runtime": "^0.
|
|
26
|
+
"@sproutboat/runtime": "^0.25.0"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/src/d1.ts
CHANGED
|
@@ -188,9 +188,24 @@ export function createD1Store(executionMs = 0, capability = "") {
|
|
|
188
188
|
switch (msg.op) {
|
|
189
189
|
case "d1.query":
|
|
190
190
|
return { ok: true, ...exec1(db, str(msg.sql), params(msg.params)) };
|
|
191
|
-
case "d1.exec":
|
|
192
|
-
|
|
191
|
+
case "d1.exec": {
|
|
192
|
+
const lines = Array.isArray(msg.lines) ? msg.lines.map(str) : null;
|
|
193
|
+
if (!strict || !lines) {
|
|
194
|
+
db.exec(str(msg.sql));
|
|
195
|
+
return { ok: true };
|
|
196
|
+
}
|
|
197
|
+
// From 2026-10-24: line by line as workerd runs it, all or nothing.
|
|
198
|
+
db.transaction(() =>
|
|
199
|
+
lines.forEach((line, i) => {
|
|
200
|
+
try {
|
|
201
|
+
db.exec(line);
|
|
202
|
+
} catch (error) {
|
|
203
|
+
throw new Error(`D1_EXEC_ERROR: Error in line ${i + 1}: ${line}: ${error instanceof Error ? error.message : String(error)}`);
|
|
204
|
+
}
|
|
205
|
+
}),
|
|
206
|
+
)();
|
|
193
207
|
return { ok: true };
|
|
208
|
+
}
|
|
194
209
|
case "d1.batch": {
|
|
195
210
|
const statements = Array.isArray(msg.statements) ? msg.statements.map((s) => jsonObject(s) ?? {}) : [];
|
|
196
211
|
return {
|