mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
999bf3d097
If a table is joined multiple times, those tables are aliased other than the first one. It happens easily on self referential associations, and in that case currently there is no way to work custom attribute (type casting) and attribute alias resolution for aliased tables in `where` conditions. To address the issue, it will allow `where` references association names as table aliases. If association names are referenced in `where`, those names are used for joined table alias names. ```ruby class Comment < ActiveRecord::Base enum label: [:default, :child] has_many :children, class_name: "Comment", foreign_key: :parent_id end # ... FROM comments LEFT OUTER JOIN comments children ON ... WHERE children.label = 1 Comment.includes(:children).where("children.label": "child") ``` Fixes #39727. |
||
---|---|---|
.. | ||
mysql2_specific_schema.rb | ||
oracle_specific_schema.rb | ||
postgresql_specific_schema.rb | ||
schema.rb | ||
sqlite_specific_schema.rb |