Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4558 from stephencelis/type-cast-unknown-should-fail

Don't type-cast unknown types to YAML.
  • Loading branch information...
commit 01176a7eaf40577e298b2c6e120e3fa17feabcc7 2 parents 47addcc + 920070e
Aaron Patterson tenderlove authored
2  activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
View
@@ -71,7 +71,7 @@ def type_cast(value, column)
when Date, Time then quoted_date(value)
when Symbol then value.to_s
else
- YAML.dump(value)
+ raise TypeError, "can't cast #{value.class} to #{column.type}"
end
end
4 activerecord/test/cases/adapters/sqlite3/quoting_test.rb
View
@@ -70,9 +70,9 @@ def test_type_cast_bigdecimal
assert_equal bd.to_f, @conn.type_cast(bd, nil)
end
- def test_type_cast_unknown
+ def test_type_cast_unknown_should_raise_error
obj = Class.new.new
- assert_equal YAML.dump(obj), @conn.type_cast(obj, nil)
+ assert_raise(TypeError) { @conn.type_cast(obj, nil) }
end
def test_quoted_id
8 activerecord/test/cases/base_test.rb
View
@@ -992,10 +992,9 @@ def test_dup
assert_equal "b", duped_topic.title
# test if the attribute values have been duped
- topic.title = {"a" => "b"}
duped_topic = topic.dup
- duped_topic.title["a"] = "c"
- assert_equal "b", topic.title["a"]
+ duped_topic.title.replace "c"
+ assert_equal "a", topic.title
# test if attributes set as part of after_initialize are duped correctly
assert_equal topic.author_email_address, duped_topic.author_email_address
@@ -1006,8 +1005,7 @@ def test_dup
assert_not_equal duped_topic.id, topic.id
duped_topic.reload
- # FIXME: I think this is poor behavior, and will fix it with #5686
- assert_equal({'a' => 'c'}.to_yaml, duped_topic.title)
+ assert_equal("c", duped_topic.title)
end
def test_dup_with_aggregate_of_same_name_as_attribute

1 comment on commit 01176a7

Arun Agrawal
Collaborator

Seems after this Build is broken :-(

Please sign in to comment.
Something went wrong with that request. Please try again.