-
Notifications
You must be signed in to change notification settings - Fork 209
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(d1): too many parameters when preparing a D1 statement #504
Comments
looks like miniflare/packages/d1/src/d1js.ts Line 113 in 2d0fbc6
My guess is this is where the error happens? But this is just better-sqlite? miniflare/packages/d1/src/api.ts Line 135 in 2d0fbc6
|
|
Facing the same issue. :( |
`better-sqlite3` expects parameters of the form `?1, ?2, ...` to be bound as an object of the form `{ 1: params[0], 2: params[1], ...}`. In #480, we accidentally removed the code that handled this case. This PR adds it back, and lifts out some common functionality into a `#prepareAndBind()` function. :) Thanks @ruslantalpa for spotting the removed code. Closes #526 Closes cloudflare/workers-sdk#2811 Closes cloudflare/workers-sdk#2887
…544) `better-sqlite3` expects parameters of the form `?1, ?2, ...` to be bound as an object of the form `{ 1: params[0], 2: params[1], ...}`. In #480, we accidentally removed the code that handled this case. This PR adds it back, and lifts out some common functionality into a `#prepareAndBind()` function. :) Thanks @ruslantalpa for spotting the removed code. Closes #526 Closes cloudflare/workers-sdk#2811 Closes cloudflare/workers-sdk#2887
Hi is it possible this issue is not resolved yet? const keys = Object.keys(convertedEntity);
const valuesPlaceholders = keys.map((_, index) => `?${index + 1}`).join(', ');
const values = Object.values(convertedEntity);
const stmt = this.db.prepare(`INSERT INTO ${collectionName} (${keys.map(key => `"${key}"`).join(', ')}) VALUES (${valuesPlaceholders});`).bind(...values);
await stmt.run(); |
just upgraded to wrangler 2.10.0 and getting new D1_ERROR which has the new miniflare version
I'm only trying to bind 4 values. Example
Note this runs fine in CF workers.
The text was updated successfully, but these errors were encountered: