You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I'm having a problem using Deterministic ordering with Polymorphic hierarchies with STI.
In my project I'm moving elements of different types. When I move an element in between it's siblings the resulting SQL statement updates the sort_order column of only elements of the same type.
For example:
Element A is type "Text" with "sort_order" 1
Element B is type "Group" with "sort_order" 2
Element C is type "Photo" with "sort_order" 3
All of these elements have the same parent.
If I prepend Element A to C then the resulting SQL statement is:
UPDATE elements SET sort_order = sort_order - 1 WHERE elements.type IN ('Photo') AND (parent_id = ## AND sort_order <= 2))
So, only elements type "Photo" have their "sort_order" value updated resulting in:
Element C remains with a "sort_order" value of 3 while element A and B now have a "sort_order" value of 2.
How can I override this behavior and have that moving an element updates the order of all siblings before or after it?
The text was updated successfully, but these errors were encountered:
This seems like a bug! We need to make a breaking test, then fix the implementation. I'll try to get to this soon. If you send me a pull request with either the test, or the bugfix, that would certainly be helpful.
Hey thank you so much man. Great job. And I'm soooo sorry I couldn't help sending a breaking test at least but I'm such a noob in ruby on rails that I couldn't even get a decent test in order. I'm surprised I actually detected a bug!
Hello, I'm having a problem using Deterministic ordering with Polymorphic hierarchies with STI.
In my project I'm moving elements of different types. When I move an element in between it's siblings the resulting SQL statement updates the sort_order column of only elements of the same type.
For example:
If I prepend Element A to C then the resulting SQL statement is:
UPDATE
elements
SETsort_order
=sort_order
- 1 WHEREelements
.type
IN ('Photo') AND (parent_id
= ## ANDsort_order
<= 2))So, only elements type "Photo" have their "sort_order" value updated resulting in:
Element C remains with a "sort_order" value of 3 while element A and B now have a "sort_order" value of 2.
How can I override this behavior and have that moving an element updates the order of all siblings before or after it?
The text was updated successfully, but these errors were encountered: