aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/serialized_attribute_test.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-07-04 06:18:37 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-08-16 18:47:16 +0900
commitc6a62dc327c54baec87306f5c381e13cacc00a19 (patch)
treee1fce0374a899b49a00afb987ddfdb1686a43b7a /activerecord/test/cases/serialized_attribute_test.rb
parentc6900ce1bb3dc2daf7cd1ecfdeeb276f2e9645b5 (diff)
downloadrails-c6a62dc327c54baec87306f5c381e13cacc00a19.tar.gz
rails-c6a62dc327c54baec87306f5c381e13cacc00a19.tar.bz2
rails-c6a62dc327c54baec87306f5c381e13cacc00a19.zip
Do not handle as an associated predicate if a table has the column
If handled as an associated predicate even though a table has the column, will generate invalid SQL by valid column name treated as a table name.
Diffstat (limited to 'activerecord/test/cases/serialized_attribute_test.rb')
-rw-r--r--activerecord/test/cases/serialized_attribute_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/serialized_attribute_test.rb b/activerecord/test/cases/serialized_attribute_test.rb
index ceb0d5441b..bebd856faf 100644
--- a/activerecord/test/cases/serialized_attribute_test.rb
+++ b/activerecord/test/cases/serialized_attribute_test.rb
@@ -157,6 +157,13 @@ class SerializedAttributeTest < ActiveRecord::TestCase
assert_equal(settings, Topic.find(topic.id).content)
end
+ def test_where_by_serialized_attribute_with_hash
+ settings = { "color" => "green" }
+ Topic.serialize(:content, Hash)
+ topic = Topic.create!(content: settings)
+ assert_equal topic, Topic.where(content: settings).take
+ end
+
def test_serialized_default_class
Topic.serialize(:content, Hash)
topic = Topic.new