Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: wrangler D1 not binding BLOB in the same format than cloud D1 #2527

Closed
JoshVazq opened this issue Jan 11, 2023 · 0 comments · Fixed by cloudflare/miniflare#480
Closed
Labels
bug Something that isn't working d1 Relating to D1 miniflare Relating to Miniflare

Comments

@JoshVazq
Copy link

JoshVazq commented Jan 11, 2023

Which Cloudflare product(s) does this pertain to?

D1, Wrangler

What version of Wrangler are you using?

2.6.2 and 2.7.1

What operating system are you using?

Linux

Describe the Bug

In summary there is an inconsistency between wrangler miniflare sqlite and D1.

D1 produces an error whenever an insert with a blob on non array format
params to be an array of string | number | boolean | null | array

sqlite produces an error whenever an insert with a blob on non Uint8Array
SQLite3 can only bind numbers, strings, bigints, buffers, and null

Sample DB:
CREATE TABLE test_blob ( value BLOB NOT NULL);
This code works in D1 but not in local:

 const value = crypto.getRandomValues(new Uint8Array(12))
  await d1
  .prepare('INSERT INTO test_blob(value) VALUES(?1)' )
  .bind(Array.from(value))
  .run();

This code runs in local but not in D1:

 const value = crypto.getRandomValues(new Uint8Array(12))
  await d1
  .prepare('INSERT INTO test_blob(value) VALUES(?1)' )
  .bind(value)
  .run();

Miniflare relatedCode
https://github.com/cloudflare/miniflare/blob/master/packages/d1/src/statement.ts

Based on this:
https://github.com/cloudflare/wrangler2/blob/main/packages/wrangler/templates/d1-beta-facade.js

Shouldn't D1 accept ArrayBuffers and Uint8Array?

I apologize if I'm mistaken with my assumptions or if this is the issue has to be opened somewhere else.

@JoshVazq JoshVazq added the bug Something that isn't working label Jan 11, 2023
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Jan 11, 2023
@JacobMGEvans JacobMGEvans added the d1 Relating to D1 label Jan 12, 2023
@JacobMGEvans JacobMGEvans moved this from Untriaged to Other in workers-sdk Jan 12, 2023
@rozenmd rozenmd removed this from workers-sdk Jan 19, 2023
@rozenmd rozenmd added the miniflare Relating to Miniflare label Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working d1 Relating to D1 miniflare Relating to Miniflare
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants