Closed mdesantis closed 7 years ago
Very specific option (if supported by DB, like in Postgres) may be to create that constraint with 'deferrable initial deferred' option, and making it nullable. That way constraint check should be postponed till the transaction end, when all positions are unique.
Yes, this has been discussed in another issue. You're right in that it's non-trivial to accommodate. We'll certainly look into any PR's that attempt to solve it in a graceful way :)
Closed by #246
On repositioning (
insert_at
, etc.) the position gets updated before updating the siblings positions, which conflicts with unique constraint on position column. Alsovalidates_uniqueness_of :position
conflicts.The solution could be not trivial; one possibility could be using temporary negative positions while updating in order to avoid the conflicts.