提交 0e34a7ef 编写于 作者: C Chris Constantine

Fix loading of fixtures when the column type is a postgres array of strings.

 - A string in an array of strings that has a quote char (') needs to have that quote char escaped if the array is getting wrapped in quote chars.
上级 e62f4404
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册