sigbotai
sigbotai
DTDrizzle Team
Created by Meexa on 12/7/2023 in #help
How to do "onConflictDoUpdate" when inserting an array of values?
Oh, I have figured it out. I made a mistake in my post table definition
16 replies
DTDrizzle Team
Created by Meexa on 12/7/2023 in #help
How to do "onConflictDoUpdate" when inserting an array of values?
sqlexcluded.yourColumnName this does not work with postgres. It throws an error: column excluded.yourColumnName does not exist In my case, I am doing:
await db
.insert(posts)
.values([
{ id: 2, text: "I am trying to insert something", authorId: 3 },
{ id: 3, text: "I am tired of trying", authorId: 3 },
])
.onConflictDoUpdate({ target: posts.id, set: { text: sql`excluded.text` } })
await db
.insert(posts)
.values([
{ id: 2, text: "I am trying to insert something", authorId: 3 },
{ id: 3, text: "I am tired of trying", authorId: 3 },
])
.onConflictDoUpdate({ target: posts.id, set: { text: sql`excluded.text` } })
So, I get the error: column excluded.text does not exist
16 replies