Permalink
Browse files

Merge pull request #10264 from cconstantine/master

Postgresql array columns don't properly escape single quote strings when loading fixtures
  • Loading branch information...
2 parents 1d9309a + 0e34a7e commit d098e1c24bc145e0cc14532348436e14dc46d375 @rafaelfranca rafaelfranca committed Apr 19, 2013
@@ -32,7 +32,7 @@ def quote(value, column = nil) #:nodoc:
when 'point' then super(PostgreSQLColumn.point_to_string(value))
else
if column.array
- "'#{PostgreSQLColumn.array_to_string(value, column, self)}'"
+ "'#{PostgreSQLColumn.array_to_string(value, column, self).gsub(/'/, "''")}'"
else
super
end
@@ -81,6 +81,12 @@ def test_contains_nils
assert_cycle(['1',nil,nil])
end
+ def test_insert_fixture
+ tag_values = ["val1", "val2", "val3_with_'_multiple_quote_'_chars"]
+ @connection.insert_fixture({"tags" => tag_values}, "pg_arrays" )
+ assert_equal(PgArray.last.tags, tag_values)
+ end
+
private
def assert_cycle array
# test creation

0 comments on commit d098e1c

Please sign in to comment.