When inserting a row into CockroachDB using ib/pq and the stmt.Exec function, the library incorrectly escapes special characters in the input string, resulting in an invalid JSON string being inserted into the database. It appears that the library is escaping the input string twice, even though it's already escaped.
Steps to Reproduce
Prepare a statement for inserting a row into a CockroachDB table using pq.CopyIn.
Call stmt.Exec with a value that contains special characters and is already escaped, such as {"body":"value with escaped special \" character"}.
Check the inserted row in the database and observe that the special characters are incorrectly escaped, resulting in an invalid JSON string.
Expected Behavior
The library should correctly handle input strings that are already escaped and should not escape them again.
Actual Behavior
The library incorrectly escapes input strings that are already escaped, resulting in an invalid JSON string.
Versions
lib/pq version: v1.10.7
CockroachDB version: v22.2
Go version: go1.20.3 linux/amd64
Description
When inserting a row into CockroachDB using
ib/pq
and thestmt.Exec
function, the library incorrectly escapes special characters in the input string, resulting in an invalid JSON string being inserted into the database. It appears that the library is escaping the input string twice, even though it's already escaped.Steps to Reproduce
pq.CopyIn
.stmt.Exec
with a value that contains special characters and is already escaped, such as{"body":"value with escaped special \" character"}
.Expected Behavior
The library should correctly handle input strings that are already escaped and should not escape them again.
Actual Behavior
The library incorrectly escapes input strings that are already escaped, resulting in an invalid JSON string.
Versions
lib/pq version: v1.10.7 CockroachDB version: v22.2 Go version: go1.20.3 linux/amd64