go-jet / jet

Type safe SQL builder with code generation and automatic query result data mapping
Apache License 2.0
2.52k stars 118 forks source link

How to update all columns on conflict #238

Open go-jet opened 1 year ago

go-jet commented 1 year ago

Discussed in https://github.com/go-jet/jet/discussions/237

Originally posted by **rsmidt** May 17, 2023 I'm trying to implement a basic upsert where I want to update all fields as soon as I hit a constraint, e.g. ```go Users. INSERT(Users.AllColumns). MODEL(user). ON_CONFLICT(Users.ID). DO_UPDATE( SET(Users.AllColumns.SET(Users.EXCLUDED.AllColumns)), ) ``` Unfortunately, this doesn't compile. Am I doing something wrong here? Is there maybe a better way to achieve the upsert?