rails / arel

A Relational Algebra
2.06k stars 390 forks source link

Atomic upsert? #520

Closed glebm closed 6 years ago

glebm commented 6 years ago

A basic upsert has three inputs:

  1. Values to insert.
  2. Values to update if insertion failed because of a unique index / constraint conflict.
  3. Values to return.

All databases supported by Arel support a form upsert:

The lowest common denominator between all these databases is that the conflicting values must belong to a single unique index (there is no way to select them explicitly).

it'd be nice to have a cross-database way to do it (useful for library authors).

Is Arel at the right abstraction level to provide it?

matthewd commented 6 years ago

Per #523, Arel development is moving to rails/rails.

If this issue is still relevant, please consider reopening it over there. (Note that the Rails repository does not accept feature request issues, and requires reproduction steps that rely on Active Record's documented API.)

mhuggins commented 6 years ago

Where can I find the issue for this in rails/rails?