Closed ctaity-treinta closed 1 month ago
on conflict do merge
is not valid SQL.
You might find this interesting/useful, where I add a type OnConflictUpdateCardSet
so I get a type error if I add and don't handle a column: https://github.com/AlexErrant/Pentive/blob/0d3dc078952176a4cdbdeeb45253719f191eea43/app/src/sqlite/card.ts#L404-L410
I think would be very useful have the columns to update all columns of the table, is a use case vert common.
You can't update a PK, and kysely doesn't know what the PK is. There's no general solution for this so you'll need to write it yourself. Also, you probably won't want to update a createdAt
column.
but if i sent to insert { a, b, c ,d } and the conflict is on field a, you could update b, c, d, you have a point with createdAt, but also createdAt and updateAt columns usually are implemented as default values.
Let me emphasize: kysely doesn't know what the PK is. Kysley is not an ORM.
and the conflict is on field a
That error occurs at runtime, which is not kysely's domain.
Hi, i would like to kown if exists a way to do something like this:
and in doMerge, add all table fields, like doing an upsert, like knex merge, without need specify each field?