I'm trying to execute UPSERT on a table, where the unique index is a composite index - composed of multiple columns (node_id and name in my case). Unfortunately, it seems that the upsert method doesn't allow passing multiple expressions/columns as an onConflictOf argument.
A possible solution would be to allow passing an array instead of just a single expression, e.g.:
// ...
let expNodeId = Expression<Int64>("node_id")
let expName = Expression<String>("name")
let expValue = Expression<String>("value")
myTable.upsert(expValue <- "foo", onConflictOf: [expNodeId, expName])
which would produce a valid UPSERT expression:
INSERT INTO "myTable" ("value") VALUES ('foo') ON CONFLICT ("node_id" , "name") DO UPDATE SET "node_id" = "excluded"."node_id", "name" = "excluded"."name", "value" = "excluded"."value"
Build Information
Issue
I'm trying to execute UPSERT on a table, where the unique index is a composite index - composed of multiple columns (
node_id
andname
in my case). Unfortunately, it seems that theupsert
method doesn't allow passing multiple expressions/columns as anonConflictOf
argument.A possible solution would be to allow passing an array instead of just a single expression, e.g.:
which would produce a valid UPSERT expression:
UPDATE: As a workaround, I ended up with this: