Skip to content

No idea to escape single quote' and double quote". #56

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

Closed
kmvan opened this issue Nov 27, 2020 · 1 comment
Closed

No idea to escape single quote' and double quote". #56

kmvan opened this issue Nov 27, 2020 · 1 comment
Labels

Comments

@kmvan
Copy link

kmvan commented Nov 27, 2020

const sql = sqlstring.format('SELECT * FROM `terms` WHERE `name` = ?', [
    `single'double"`,
  ])
console.log(sql)
// output: SELECT * FROM `terms` WHERE `name` = 'single\'double\"'
// near "double": syntax error

Looks like single\'double\" shoud be single''double""
Need I create a user function to replace the quote?

@dougwilson
Copy link
Member

Hi @kmvan sorry you are having trouble. These methods of escaping values only works when the NO_BACKSLASH_ESCAPES SQL mode is disabled (which is the default state for MySQL servers).

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

No branches or pull requests

2 participants