diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-06-14 23:48:01 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-06-19 22:21:51 +0900 |
commit | 15e3e9cdccd8ab0d204ed9e74bf7916d6025d405 (patch) | |
tree | 2b5588e1f5936fabd7ee6b12a883b00799ce7f81 /activerecord/test/models | |
parent | 2be5ef6a1d5baebcb749c42a48628c741570fd73 (diff) | |
download | rails-15e3e9cdccd8ab0d204ed9e74bf7916d6025d405.tar.gz rails-15e3e9cdccd8ab0d204ed9e74bf7916d6025d405.tar.bz2 rails-15e3e9cdccd8ab0d204ed9e74bf7916d6025d405.zip |
Ensure to calculate column aliases after all table aliases are constructed
Currently, column aliases which is used for eager loading are calculated
before constructing all table aliases in FROM clause.
`JoinDependency#join_constraints` constructs table aliases for `joins`
first, and then always re-constructs table aliases for eager loading.
If both `joins` and eager loading are given a same table association,
the re-construction would cause the discrepancy between column aliases
and table aliases.
To avoid the discrepancy, the column aliases should be calculated after
all table aliases are constructed.
Fixes #30603.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/member.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/test/models/member.rb b/activerecord/test/models/member.rb index 4315ba1941..6e33ac0a6d 100644 --- a/activerecord/test/models/member.rb +++ b/activerecord/test/models/member.rb @@ -26,13 +26,14 @@ class Member < ActiveRecord::Base has_one :club_category, through: :club, source: :category has_one :general_club, -> { general }, through: :current_membership, source: :club - has_many :current_memberships, -> { where favourite: true } - has_many :clubs, through: :current_memberships + has_many :super_memberships + has_many :favourite_memberships, -> { where(favourite: true) }, class_name: "Membership" + has_many :clubs, through: :favourite_memberships has_many :tenant_memberships has_many :tenant_clubs, through: :tenant_memberships, class_name: "Club", source: :club - has_one :club_through_many, through: :current_memberships, source: :club + has_one :club_through_many, through: :favourite_memberships, source: :club belongs_to :admittable, polymorphic: true has_one :premium_club, through: :admittable |