8000 Fix encoding of backslashes in arrays by dylex · Pull Request #110 · mauricio/postgresql-async · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.

Fix encoding of backslashes in arrays #110

Merged
merged 1 commit into from
Nov 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class PostgreSQLColumnEncoderRegistry extends ColumnEncoderRegistry {
"NULL"
} else {
if (this.shouldQuote(item)) {
"\"" + this.encode(item).replaceAllLiterally("\"", """\"""") + "\""
"\"" + this.encode(item).replaceAllLiterally("\\", """\\""").replaceAllLiterally("\"", """\"""") + "\""
} else {
this.encode(item)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ArrayTypesSpec extends Specification with DatabaseTestHelper {
(smallint_column, text_column, timestamp_column)
values (
'{1,2,3,4}',
'{"some,\"comma,separated,text","another line of text",NULL}',
'{"some,\"comma,separated,text","another line of text","fake\,backslash","real\\,backslash\\",NULL}',
'{"2013-04-06 01:15:10.528-03","2013-04-06 01:15:08.528-03"}'
)"""

Expand All @@ -52,7 +52,7 @@ class ArrayTypesSpec extends Specification with DatabaseTestHelper {
executeDdl(handler, insert, 1)
val result = executeQuery(handler, "select * from type_test_table").rows.get
result(0)("smallint_column") === List(1,2,3,4)
result(0)("text_column") === List("some,\"comma,separated,text", "another line of text", null )
result(0)("text_column") === List("some,\"comma,separated,text", "another line of text", "fake,backslash", "real\\,backslash\\", null )
result(0)("timestamp_column") === List(
TimestampWithTimezoneEncoderDecoder.decode("2013-04-06 01:15:10.528-03"),
TimestampWithTimezoneEncoderDecoder.decode("2013-04-06 01:15:08.528-03")
Expand All @@ -68,7 +68,7 @@ class ArrayTypesSpec extends Specification with DatabaseTestHelper {
TimestampWithTimezoneEncoderDecoder.decode("2013-04-06 01:15:08.528-03")
)
val numbers = List(1,2,3,4)
val texts = List("some,\"comma,separated,text", "another line of text", null )
val texts = List("some,\"comma,separated,text", "another line of text", "fake,backslash", "real\\,backslash\\", null )

withHandler {
handler =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class DefaultColumnEncoderRegistrySpec extends Specification {

"correctly render an array of strings with nulls" in {
val items = Array( "some", """text \ hoes " here to be seen""", null, "all, right" )
registry.encode( items ) === """{"some","text \ hoes \" here to be seen",NULL,"all, right"}"""
registry.encode( items ) === """{"some","text \\ hoes \" here to be seen",NULL,"all, right"}"""
}

"correctly render an array of numbers" in {
Expand Down
0