Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/pq incorrectly escapes input strings that are already escaped #1118

Open
mohammadv184 opened this issue Apr 15, 2023 · 0 comments
Open

Comments

@mohammadv184
Copy link

Description

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

  1. Prepare a statement for inserting a row into a CockroachDB table using pq.CopyIn.
  2. Call stmt.Exec with a value that contains special characters and is already escaped, such as {"body":"value with escaped special \" character"}.
  3. 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

mohammadv184 added a commit to mohammadv184/pq that referenced this issue Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant