acts_as_list icon indicating copy to clipboard operation
acts_as_list copied to clipboard

move_higher and move_lower do not respect sequential_updates=true

Open dan98765 opened this issue 4 years ago • 1 comments

move_higher and move_lower do not respect sequential_updates=true

move_higher method: https://github.com/brendon/acts_as_list/blob/eb972421e2b9db70b3993b13a958f57c89b0e6b0/lib/acts_as_list/active_record/acts/list.rb#L98

Most of the methods in list.rb end up calling insert_at_position eventually, which will eventually check sequential_updates? and behave accordingly. Not so move_higher and move_lower.

Suggestions:

  1. Have them also use insert_at_position somehow
  2. Have them do their own check of sequential_updates? and behave differently if true
  3. Update README section about sequential_updates option to warn that these methods should never be used if you have a unique constraint in your table.

I'm happy to help out, but would appreciate maintainer(s) giving a sanity check here first as to if this is really an issue or I'm missing something, and which suggestion here (or a new one altogether) they prefer.

dan98765 avatar Apr 23 '20 19:04 dan98765

Hi @dan98765, you're right about sequential_updates only being applied to some sections of the code. I think this was an oversight by the person who originally proposed that code. If you're keen to do a PR around adding sequential update support to those methods I'd be happy to look it over for you. Someone else is also working on a refactor of the overall logic here: https://github.com/brendon/acts_as_list/pull/372 but the proposal there is to remove these helper methods from the core and add them back in as an option.

brendon avatar Apr 23 '20 21:04 brendon