Skip to content

mysql2/promise escaping apostrophes on insert #3531

Open
@jasonmacer

Description

@jasonmacer

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions