Skip to content

mysql2/promise escaping apostrophes on insert #3531

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

Open
jasonmacer opened this issue Apr 10, 2025 · 1 comment
Open

mysql2/promise escaping apostrophes on insert #3531

jasonmacer opened this issue Apr 10, 2025 · 1 comment

Comments

@jasonmacer
Copy link

I am running into an issue where I am setting a variable to JSON.stringify() and then inserting that as the value into a JSON column in the database.

Here is the variable value before the insert statement (statement is trimmed):

{"56":"Describe any cramping or pain you may have<br><br><br><br>blank line then new line's here","57":"Yes","58":"pain at any other time<br><br>next line's<br><br><br><br>blank lines then next"}

And then, after the insert statement, it looks like this:

{"56":"Describe any cramping or pain you may have<br><br><br><br>blank line then new line\'s here","57":"Yes","58":"pain at any other time<br><br>next line\'s<br><br><br><br>blank lines then next"}

If you'll look at 56, 58 (and there are others) you'll notice that in the variable value before the insert the apostrophes are not escaped; however, on the insert they are.

What am I missing here?

I appreciate anyone's assistance.

TIA!

Jason

@sidorares
Copy link
Owner

hi @jasonmacer , could you create a small self contained example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants