drizzle-orm
drizzle-orm copied to clipboard
[BUG]: onConflictDoUpdate where clause not
What version of drizzle-orm are you using?
0.25.2
What version of drizzle-kit are you using?
0.17.6
Describe the Bug
In PostgreSQL, with this call I get the following SQL
db.insert(entities)
.values({ externalId: '1', hash: '2' })
.onConflictDoUpdate({
target: [entities.externalId],
set: {
hash: sql`excluded.hash`
},
where: sql`entities.hash != excluded.hash`
})
.toSQL();
insert into "entities" ("external_id", "hash") values ($1, $2) on conflict ("external_id") where entities.hash != excluded.hash do update set "hash" = excluded.hash'
Expected behavior
I should get this SQL instead
{
insert into "entities" ("external_id", "hash") values ($1, $2) on conflict ("external_id") do update set "hash" = excluded.hash' where entities.hash != excluded.hash
The where clause should be after the set clause.
Environment & setup
No response