aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorZach Ohlgren <zach@ohlgren.me>2013-04-25 17:20:33 -0700
committerZach Ohlgren <zach@ohlgren.me>2013-05-06 17:03:18 -0700
commita6bc35c82cd58aac61608391f38fda4e034be0f7 (patch)
treeb110ba105bf47c6ca82e8f4a72cd0269e0ce0033 /activerecord
parentc9e4c9acdc0b68500fab7a5a4887303cbd3975d2 (diff)
downloadrails-a6bc35c82cd58aac61608391f38fda4e034be0f7.tar.gz
rails-a6bc35c82cd58aac61608391f38fda4e034be0f7.tar.bz2
rails-a6bc35c82cd58aac61608391f38fda4e034be0f7.zip
Fix bug in ActiveRecord::Sanitization#sanitize_sql_hash_for_conditions
Fixing CHANGLOG description Remove extra line. Remove blank lines.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md13
-rw-r--r--activerecord/lib/active_record/sanitization.rb2
-rw-r--r--activerecord/test/cases/sanitize_test.rb4
3 files changed, 15 insertions, 4 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 1304bcb7e4..a3c01bd03b 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -1,3 +1,10 @@
+* Fixed a bug in ActiveRecord#sanitize_sql_hash_for_conditions in which
+ `self.class` is an argument to PredicateBuilder#build_from_hash
+ causing PredicateBuilder to call non-existant method
+ Class#reflect_on_association.
+
+ *Zach Ohlgren*
+
* While removing index if column option is missing then raise IrreversibleMigration exception.
Following code should raise `IrreversibleMigration`. But the code was
@@ -80,9 +87,9 @@
* Abort a rake task when missing db/structure.sql like `db:schema:load` task.
*kennyj*
-
+
* rake:db:test:prepare falls back to original environment after execution.
-
+
*Slava Markevich*
-Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activerecord/CHANGELOG.md) for previous changes.
+Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activerecord/CHANGELOG.md) for previous changes. \ No newline at end of file
diff --git a/activerecord/lib/active_record/sanitization.rb b/activerecord/lib/active_record/sanitization.rb
index 3c5b871e99..0ed97b66d6 100644
--- a/activerecord/lib/active_record/sanitization.rb
+++ b/activerecord/lib/active_record/sanitization.rb
@@ -89,7 +89,7 @@ module ActiveRecord
attrs = expand_hash_conditions_for_aggregates(attrs)
table = Arel::Table.new(table_name, arel_engine).alias(default_table_name)
- PredicateBuilder.build_from_hash(self.class, attrs, table).map { |b|
+ PredicateBuilder.build_from_hash(self, attrs, table).map { |b|
connection.visitor.accept b
}.join(' AND ')
end
diff --git a/activerecord/test/cases/sanitize_test.rb b/activerecord/test/cases/sanitize_test.rb
index 817897ceac..09e02b29da 100644
--- a/activerecord/test/cases/sanitize_test.rb
+++ b/activerecord/test/cases/sanitize_test.rb
@@ -5,6 +5,10 @@ class SanitizeTest < ActiveRecord::TestCase
def setup
end
+ def test_sanitize_sql_hash_handles_associations
+ assert_equal "`adorable_animals`.`name` = 'Bambi'", Binary.send(:sanitize_sql_hash, {adorable_animals: {name: 'Bambi'}})
+ end
+
def test_sanitize_sql_array_handles_string_interpolation
quoted_bambi = ActiveRecord::Base.connection.quote_string("Bambi")
assert_equal "name=#{quoted_bambi}", Binary.send(:sanitize_sql_array, ["name=%s", "Bambi"])