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 failed on d1 parameter bindings with ?NNN #2887

Closed
yw662 opened this issue Mar 9, 2023 · 1 comment · Fixed by cloudflare/miniflare#544 or #2942
Closed

🐛 BUG: Wrangler failed on d1 parameter bindings with ?NNN #2887

yw662 opened this issue Mar 9, 2023 · 1 comment · Fixed by cloudflare/miniflare#544 or #2942
Labels
bug Something that isn't working

Comments

@yw662
Copy link

yw662 commented Mar 9, 2023

Which Cloudflare product(s) does this pertain to?

D1

What version of Wrangler are you using?

2.12.2

What operating system are you using?

macos 13.1

Describe the Bug

These code would throw Too many parameter values were provided in wrangler:

const stmt = d1.prepare('select ?1 + ?2').bind(1, 2)
const stmt = d1.prepare('select ? + ?1').bind(1)

This would throw Missing named parameters:

const stmt = this.d1.prepare('select ? + ?2').bind(1)

While this passes:

const stmt = this.d1.prepare('select ? + ?').bind(1, 2)
{
  "results": [ { "? + ?": 3 } ],
  "success": true
}
@yw662 yw662 added the bug Something that isn't working label Mar 9, 2023
@mhujer
Copy link

mhujer commented Mar 12, 2023

This is related to cloudflare/miniflare#504

mrbbot added a commit to cloudflare/miniflare that referenced this issue Mar 22, 2023
`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
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
Projects
Archived in project
2 participants