upsert with excluded using column name

I'm trying to do a an upsert like so
await db.insert(user).values(values).onConflictDoUpdate({
  target: user.id,
  set: {
    // Defined in schema as full_name
    fullName: sql`EXCLUDED.${user.fullName.name}`
}
})

When I try to do this, I'm getting error PostgresError: syntax error at or near "$265". If I do
fullName: sql`EXCLUDED.full_name` 
, it works. But I would like to do so using the .name property as it will be easier to catch if there's an issue. How do I do it?
Solution
Hello @vr7bd. You can follow this guide to do upsert
https://orm.drizzle.team/learn/guides/upsert

In your case should be

await db.insert(user).values(values).onConflictDoUpdate({
  target: user.id,
  set: {
    // Defined in schema as full_name
    fullName: sql.raw(`excluded.${user.fullName.name}`)
}
})
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Was this page helpful?