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
Ensure none constraint scopes don’t trigger a query
rails#47800 refactored how `Relation#none` worked, and one side effect of this change was that if you had an association like this:
`has_many :comments_none, ->(post) { none }, class_name: "Comment”`
reading the association caused a query to happen, despite the `none` in the passed in scope.
As it turns out, this is because the association performs a merge of the two scopes, and the `@none` instance variable wasn’t getting copied over to the merged scope, so the upfront guard clause checking `@none` in `#exec_main_query`.
Updating the `Merger` object to add a check for null relations and call `none!` ensures the query doesn’t run in this particular scenario.
0 commit comments