Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken with unique constraint on position #245

Closed
mdesantis opened this issue Dec 20, 2016 · 3 comments
Closed

Broken with unique constraint on position #245

mdesantis opened this issue Dec 20, 2016 · 3 comments

Comments

@mdesantis
Copy link

mdesantis commented Dec 20, 2016

On repositioning (insert_at, etc.) the position gets updated before updating the siblings positions, which conflicts with unique constraint on position column. Also validates_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.

@zharikovpro
Copy link
Contributor

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.

@brendon
Copy link
Owner

brendon commented Dec 20, 2016

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 :)

@brendon
Copy link
Owner

brendon commented Jan 23, 2017

Closed by #246

@brendon brendon closed this as completed Jan 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants