diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-25 16:19:59 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-25 16:19:59 -0700 |
commit | 5b918bb97cb1801945ef778508a3738da98012c5 (patch) | |
tree | ae9962ad745422c2d77c48a25bbcfb45bb357345 /activerecord/lib/active_record/associations/has_one_association.rb | |
parent | 0a609eea504f72baead7548d47f0fe707314a033 (diff) | |
download | rails-5b918bb97cb1801945ef778508a3738da98012c5.tar.gz rails-5b918bb97cb1801945ef778508a3738da98012c5.tar.bz2 rails-5b918bb97cb1801945ef778508a3738da98012c5.zip |
using arel to compile sql statements
Diffstat (limited to 'activerecord/lib/active_record/associations/has_one_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/has_one_association.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb index c49fd6e66a..d08cbea199 100644 --- a/activerecord/lib/active_record/associations/has_one_association.rb +++ b/activerecord/lib/active_record/associations/has_one_association.rb @@ -89,7 +89,8 @@ module ActiveRecord "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " + "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}" else - sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}" + test = owner_quoted_id == "NULL" ? "IS" : "=" + sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} #{test} #{owner_quoted_id}" end sql << " AND (#{conditions})" if conditions { :conditions => sql } |