acts_as_list icon indicating copy to clipboard operation
acts_as_list copied to clipboard

Sequential updates not used when multi-column index is present

Open janklimo opened this issue 4 years ago • 6 comments

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.

janklimo avatar Sep 16 '19 05:09 janklimo

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

brendon avatar Sep 16 '19 06:09 brendon

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.

janklimo avatar Sep 16 '19 07:09 janklimo

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

brendon avatar Sep 16 '19 21:09 brendon

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

brendon avatar Apr 23 '20 21:04 brendon

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

iainbeeston avatar Nov 10 '22 11:11 iainbeeston

As far as I know it wasn’t.

brendon avatar Nov 10 '22 17:11 brendon