brendon / acts_as_list

An ActiveRecord plugin for managing lists.
http://brendon.github.io/acts_as_list/
MIT License
2.04k stars 355 forks source link

Sequential updates not used when multi-column index is present #360

Closed janklimo closed 3 months ago

janklimo commented 5 years ago

Given the following index (Postgres):

add_index :properties_images, [:property_id, :position], unique: true

sequential updates will not be used (and reordering always fail) unless explicitly specified:

acts_as_list scope: :property, sequential_updates: true

One way to fix this would be to scan all indexes of the target table in SequentialUpdatesMethodDefiner and see if any of them include position. Another way is just to mention this in the docs. Opening a conversation first.

brendon commented 5 years ago

Hi @janklimo, I've been in this position before, trying to sniff the default value of a column. It's actually more fraught than you'd expect as when a rails app boots, it's not necessarily connected to the DB yet and nor should it be (in some cases). :)

I think the best bet would just to document the feature :D I didn't realise it snuck through undocumented! Would you be interested in doing up a PR for this? :)

janklimo commented 5 years ago

Thanks for a fast response @brendon I share your sentiment on this. I think we can:

a) Try to make the gem smarter, add complexity, possibly introduce bugs (you're right, been there too 😄) b) Document the feature with the same outcome - use sequential update correctly

The latter is a clear winner for me, I'll look into it and open a PR.

brendon commented 5 years ago

Thanks @janklimo :) That's very much appreciated.

brendon commented 4 years ago

Hi @janklimo, I can't remember, did you ever put forward a documentation update? :)

iainbeeston commented 1 year ago

Did this ever get fixed? I'm seeing the same issue now 😞

brendon commented 1 year ago

As far as I know it wasn’t.

brendon commented 3 months ago

Closing due to inactivity.