diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-22 18:22:54 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-22 18:23:38 -0800 |
commit | 3e64336647fefe598ff3b0775401e2c2c5d378d3 (patch) | |
tree | 05eabd9c5ace4f7283f53fcb909623a1ae2a3240 | |
parent | 6ca921a98cefa2bce67486f1ba2a8f52f4170d78 (diff) | |
download | rails-3e64336647fefe598ff3b0775401e2c2c5d378d3.tar.gz rails-3e64336647fefe598ff3b0775401e2c2c5d378d3.tar.bz2 rails-3e64336647fefe598ff3b0775401e2c2c5d378d3.zip |
removing SQL interpolation, please use scoping and attribute conditionals as a replacement
-rw-r--r-- | activerecord/CHANGELOG | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/association_preload.rb | 7 | ||||
-rw-r--r-- | activerecord/test/cases/associations/eager_test.rb | 4 | ||||
-rw-r--r-- | activerecord/test/models/post.rb | 3 |
4 files changed, 4 insertions, 13 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index fd571c4ca4..8ebc87145c 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,8 @@ *Rails 3.1.0 (unreleased)* +* Removed support for interpolated SQL conditions. Please use scoping +along with attribute conditionals as a replacement. + * Added ActiveRecord::Base#has_secure_password (via ActiveModel::SecurePassword) to encapsulate dead-simple password usage with BCrypt encryption and salting [DHH]. Example: # Schema: User(name:string, password_digest:string, password_salt:string) diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index 9ac792fe3f..fc7c544a55 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -389,14 +389,9 @@ module ActiveRecord end end - - def interpolate_sql_for_preload(sql) - instance_eval("%@#{sql.gsub('@', '\@')}@", __FILE__, __LINE__) - end - def append_conditions(reflection, preload_options) sql = "" - sql << " AND (#{interpolate_sql_for_preload(reflection.sanitized_conditions)})" if reflection.sanitized_conditions + sql << " AND (#{reflection.sanitized_conditions})" if reflection.sanitized_conditions sql << " AND (#{sanitize_sql preload_options[:conditions]})" if preload_options[:conditions] sql end diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb index d5262b1ee4..6efb0d57e4 100644 --- a/activerecord/test/cases/associations/eager_test.rb +++ b/activerecord/test/cases/associations/eager_test.rb @@ -658,10 +658,6 @@ class EagerAssociationTest < ActiveRecord::TestCase assert_equal people(:david, :susan), Person.find(:all, :include => [:readers, :primary_contact, :number1_fan], :conditions => "number1_fans_people.first_name like 'M%'", :order => 'people.id', :limit => 2, :offset => 0) end - def test_preload_with_interpolation - assert_equal [comments(:greetings)], Post.find(posts(:welcome).id, :include => :comments_with_interpolated_conditions).comments_with_interpolated_conditions - end - def test_polymorphic_type_condition post = Post.find(posts(:thinking).id, :include => :taggings) assert post.taggings.include?(taggings(:thinking_general)) diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 0083560ebe..b51f7ff48f 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -40,9 +40,6 @@ class Post < ActiveRecord::Base has_many :author_favorites, :through => :author has_many :author_categorizations, :through => :author, :source => :categorizations - has_many :comments_with_interpolated_conditions, :class_name => 'Comment', - :conditions => ['#{"#{aliased_table_name}." rescue ""}body = ?', 'Thank you for the welcome'] - has_one :very_special_comment has_one :very_special_comment_with_post, :class_name => "VerySpecialComment", :include => :post has_many :special_comments |