3 ms·
I don't think any language can have a magic solution for a database problem. One solution is to dynamically update the value with Ecto on_conflict if possible.
by conradfr 3y ago
I don't think any language can have a magic solution for a database problem.
One solution is to dynamically update the value with Ecto on_conflict if possible.
Something like this, where you try to insert instead of update and have a constraint on the id for example:
> on_conflict: [set: [great_column: dynamic([t], fragment("? + ?", t.great_column, 1))]]
https://hexdocs.pm/ecto/constraints-and-upserts.html#constraints-and-race-conditions https://hexdocs.pm/ecto/constraints-and-upserts.html#constra...