The after_destroy callback in the list plugin causes a syntax error when reordering subclass instances whose position is defined on a root class (using class_table_inheritance) #1896
thomascchen
started this conversation in
General
Replies: 1 comment 1 reply
-
I don't think this is a bug. When you use class_table_inheritance, subclass model datasets use a subquery of a joined dataset. When you use the list plugin, the after_destroy hook uses Dataset#update to update the position of all following members in the list in a single query. That cannot work when the model's dataset is a subquery of a joined dataset. I'll update the list plugin documentation to specify that you must provide the :scope option if the model's dataset uses a subquery. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
The
after_destroy
callback in thelist
plugin that reorders entries after destroying an instance seems to cause a syntax error when trying to reorder instances of a subclass (usingclass_table_inheritance
) whose:position
field is defined on the root class and is scoped to another column, in my case a foreign key reference to another table. This seems like a bug to me, but I'm not 100% sure so thought I'd post here before opening an issue.A Simplified Example
When I try to destroy an instance of
note
(e.g.,note.destroy
), I get the following output:I was able to fix this by updating the scope on the
Item
root class to use a proc, which I adapted from here:This then gives me the following SQL output, which is more in line of what I would expect:
Is this behavior expected, and are we meant to pass a proc to the :scope option in cases like this, or does this seem like a bug? Thank you!
Beta Was this translation helpful? Give feedback.
All reactions