Skip to content

Commit 2c76887

Browse files
authoredJan 9, 2025
Fix D1 exports to properly pad HEX strings for binary values (#7701)
* Fix D1 exports to properly pad HEX strings for binary values The export logic was corrupting data when a binary value was being converted into HEX strings, and one of the bytes had a leading zero. Closes #6452 * Create green-dodos-push.md
1 parent f3c2f69 commit 2c76887

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
 

‎.changeset/green-dodos-push.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"miniflare": patch
3+
---
4+
5+
Fix D1 exports to properly pad HEX strings for binary values.

‎packages/miniflare/src/workers/d1/dumpSql.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function* dumpSql(
7171
return outputQuotedEscapedString(cell);
7272
} else if (cell instanceof ArrayBuffer) {
7373
return `X'${Array.prototype.map
74-
.call(new Uint8Array(cell), (b) => b.toString(16))
74+
.call(new Uint8Array(cell), (b) => b.toString(16).padStart(2, "0"))
7575
.join("")}'`;
7676
} else {
7777
console.log({ colType, cellType, cell, column: columns[i] });

0 commit comments

Comments
 (0)