Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #13451 from dmathieu/quoting_non_strings

Fix typecasting array of integers
  • Loading branch information...
commit c0a6ffb799c2516f8ff76a9b4bf58b2ad1b9235b 2 parents 7432d32 + 1f6a9b5
@senny senny authored
View
2  activerecord/lib/active_record/connection_adapters/postgresql/cast.rb
@@ -144,7 +144,7 @@ def escape_hstore(value)
def quote_and_escape(value)
case value
- when "NULL"
+ when "NULL", Numeric
value
else
"\"#{value.gsub(/"/,"\\\"")}\""
View
6 activerecord/test/cases/adapters/postgresql/array_test.rb
@@ -66,6 +66,12 @@ def test_type_cast_array
assert_equal([nil], @column.type_cast('{NULL}'))
end
+ def test_type_cast_integers
+ x = PgArray.new(ratings: ['1', '2'])
+ assert x.save!
+ assert_equal(['1', '2'], x.ratings)
+ end
+
def test_rewrite
@connection.execute "insert into pg_arrays (tags) VALUES ('{1,2,3}')"
x = PgArray.first
Please sign in to comment.
Something went wrong with that request. Please try again.