From 86da56a6547289515cbb327f3d7423dd226fc31a Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 17 Nov 2005 20:45:38 +0000 Subject: [PATCH] Don't add the same conditions twice in has_one finder sql. References #2916. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3074 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/CHANGELOG | 2 ++ .../lib/active_record/associations/has_one_association.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index d6464df95d333..9897ab237f3cb 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Don't add the same conditions twice in has_one finder sql. #2916 [Jeremy Evans] + * Rename Version constant to VERSION. #2802 [Marcel Molina Jr.] * Introducing the Firebird adapter. Quote columns and use attribute_condition more consistently. Setup guide: http://wiki.rubyonrails.com/rails/pages/Firebird+Adapter #1874 [Ken Kunz ] diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb index edd9e53c19f6b..8f7857ebeaa69 100644 --- a/activerecord/lib/active_record/associations/has_one_association.rb +++ b/activerecord/lib/active_record/associations/has_one_association.rb @@ -65,7 +65,7 @@ def target_obsolete? end def construct_sql - @finder_sql = "#{@association_class.table_name}.#{@association_class_primary_key_name} = #{@owner.quoted_id}#{@options[:conditions] ? " AND " + @options[:conditions] : ""}" + @finder_sql = "#{@association_class.table_name}.#{@association_class_primary_key_name} = #{@owner.quoted_id}" @finder_sql << " AND (#{sanitize_sql(@options[:conditions])})" if @options[:conditions] @finder_sql end