`Error [AssertionError]` when inserting `Buffer` in a `blob` column (SQLite)
I'm using SQLite / D1. I have a column
hash: blob("hash", { mode: "buffer" })
Whenever I try to insert values like this: .values({ hash: Buffer.from(new Uint8Array([1, 2, 3])) }
an error is thrown with cause: Error [AssertionError]: false == true
I can insert Uint8Array
or strings directly with no runtime errors, but with TypeScript errors. If i change the type (.$type<UInt8Array>
) typing works, except when querying the returned value is of course not a Uint8Array
but a Buffer
behind the scenes.
Am I missing something? Seems like blob
columns do not work with Buffer
for insertions/updates but returns Buffer
for queries2 Replies
Seems to be related to this: https://github.com/cloudflare/workers-sdk/issues/5771
GitHub
🐛 BUG: D1 via miniflare doesn't accept Buffer type for blobs · ...
Which Cloudflare product(s) does this pertain to? D1, Miniflare What version(s) of the tool(s) are you using? 3.53.1 [Wrangler] What version of Node are you using? 20.10.0 What operating system and...
I solved this for now by making an stupid custom type:
It works. This is not a Drizzle issue, but a Miniflare issue