mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Rails 5.1 point type should not raise exception if empty string is provided as value
This commit is contained in:
parent
0827f9932f
commit
e3cd321d4b
2 changed files with 9 additions and 0 deletions
|
@ -14,6 +14,8 @@ module ActiveRecord
|
|||
def cast(value)
|
||||
case value
|
||||
when ::String
|
||||
return if value.blank?
|
||||
|
||||
if value[0] == '(' && value[-1] == ')'
|
||||
value = value[1...-1]
|
||||
end
|
||||
|
|
|
@ -104,6 +104,13 @@ class PostgresqlPointTest < ActiveRecord::PostgreSQLTestCase
|
|||
assert_equal ActiveRecord::Point.new(1, 2), p.x
|
||||
end
|
||||
|
||||
def test_empty_string_assignment
|
||||
assert_nothing_raised { PostgresqlPoint.new(x: "") }
|
||||
|
||||
p = PostgresqlPoint.new(x: "")
|
||||
assert_equal nil, p.x
|
||||
end
|
||||
|
||||
def test_array_of_points_round_trip
|
||||
expected_value = [
|
||||
ActiveRecord::Point.new(1, 2),
|
||||
|
|
Loading…
Reference in a new issue