You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 13, 2025. It is now read-only.
I added these lines to one of the tests (to make sure it's not my code):
const sum = await db.prepare("SELECT ?1 + ?2 as sum").bind(1, 2).first("sum");
t.is(sum, 3);
and the test fails
d1 › test › d1js.ts › D1PreparedStatement: first
packages/d1/test/d1js.spec.ts:212
211:
212: const sum = await db.prepare("SELECT ?1 + ?2 as sum").bind(1, 2).first("sum");
213: t.is(sum, 3);
Rejected promise returned by test. Reason:
Error {
message: 'D1_ERROR',
}
› D1Database._send (packages/d1/src/d1js.ts:148:13)
› D1PreparedStatement.first (packages/d1/src/d1js.ts:215:7)
› packages/d1/test/d1js.spec.ts:212:15
─
statements.ts used to have this code which was deleted
// For statements using ?1 ?2, etc, we want to pass them as varargs but
// "better" sqlite3 wants them as an object of {1: params[0], 2: params[1], ...}
if (this.#bindings.length > 0 && typeof this.#bindings[0] !== "object") {
return prepared.bind(
Object.fromEntries(this.#bindings.map((v, i) => [i + 1, v]))
);
} else {
throw e;
}
The text was updated successfully, but these errors were encountered:
`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#526Closescloudflare/workers-sdk#2811Closescloudflare/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#526Closescloudflare/workers-sdk#2811Closescloudflare/workers-sdk#2887
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I added these lines to one of the tests (to make sure it's not my code):
and the test fails
statements.ts
used to have this code which was deletedThe text was updated successfully, but these errors were encountered: