-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Report hasn't been filed before.
- I have verified that the bug I'm about to report hasn't been filed before.
What version of drizzle-orm are you using?
0.44.6
What version of drizzle-kit are you using?
0.31.4
Other packages
No response
Describe the Bug
When creating stored procedures with placeholders, the types of set of onConflictDoUpdate do not allow placeholder values to be used.
this.insertPreparedStatement = this.db
.insert(table)
.values({
id: sql.placeholder("id"),
name: sql.placeholder("name"),
})
.onConflictDoUpdate({
target: table.id,
set: {
// Casts necessary as `set` does not accept placeholders, even though
// it works at runtime
id: sql.placeholder("id") as never,
name: sql.placeholder("name") as never,
},
})
.prepare();
However, at runtime this actually does work. Turning on logging outputs the following statement:
Query: insert into "table" ("id", "name") values (?, ?) on conflict ("table"."id") do update set "id" = ?, "name" = ? -- params: <values here>
For reference, I'm attempting to do an upsert (as described in the docs) and use a prepared statement in order to bypass the SQLite statement size limit (see cloudflare/workerd#3049 (comment)). Side note for anyone else coming across this, using the drizzle prepared statement didn't resolve the issue since the parameterized query is still considered too big.