-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Hi @AugustNagro !
I'm currently trying out Magnum and things are working really nicely!! π Thanks for this wonderful library! π
So far there was just one use case where I got stuck. I tried to format an upsert statement in Postgres SQL but could not find anything to automate the formatting of the set clause.
E.g.:
INSERT INTO user (id, name, age) VALUES (?, ?, ?)
ON CONFLICT (id) DO UPDATE SET
name = ?,
age = ?;
or the "progresque" version:
INSERT INTO user (id, name, age) VALUES (?, ?, ?)
ON CONFLICT (id) DO UPDATE SET
name = EXCLUDED.name,
age = EXCLUDED.age;
Could something like TableInfo.updateCols[T](value:T) help automate the formatting of the set clause?
sql"INSERT INTO $table ${table.insertColumns} values ($user) ON CONFLICT (${user.id}) DO UPDATE SET ${table.updsateCols(user)}"
This would be very useful when new fields are added since this would automatically include the update of values for any newly added columns.
Kind regards,
Manfred
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels