diff options
author | Tarmo Tänav <tarmo@itech.ee> | 2008-08-26 03:01:24 +0300 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-08-25 21:23:35 -0700 |
commit | a445cdd8840c4e99c40c6d5b15ab380d39a56be3 (patch) | |
tree | 1d9e7ee98e9607fd635f1743fa6c6bf507ba297e /activerecord/lib | |
parent | 2dbda11945507a0541d61d13b8c564121c1cd362 (diff) | |
download | rails-a445cdd8840c4e99c40c6d5b15ab380d39a56be3.tar.gz rails-a445cdd8840c4e99c40c6d5b15ab380d39a56be3.tar.bz2 rails-a445cdd8840c4e99c40c6d5b15ab380d39a56be3.zip |
Load the first and not the last has_one result when doing join-based eager loading
This matters when the has_one is defined with an order in which case
there is an expectation that the first one will be loaded.
[#904 state:resolved]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/associations.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 46b79c5a0d..f915daafba 100755 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1893,6 +1893,7 @@ module ActiveRecord collection.target.push(association) when :has_one return if record.id.to_s != join.parent.record_id(row).to_s + return if record.instance_variable_defined?("@#{join.reflection.name}") association = join.instantiate(row) unless row[join.aliased_primary_key].nil? record.send("set_#{join.reflection.name}_target", association) when :belongs_to |