mysql icon indicating copy to clipboard operation
mysql copied to clipboard

Variable can't contain backslash

Open chitly opened this issue 4 years ago • 3 comments

This is an example code.

const text = 'abc\\';
await client.execute('insert into users(name) values(?)', [text]);

This is a result of the query string.

insert into users(name) values("abc\")

So, it will throw an error.

chitly avatar Jun 18 '20 13:06 chitly

@chitly Thanks chitly, it's a really good issue. @manyuanrong @zhmushan It should be an escape issue. Since this lib depends on module sql_builder, I prefer to handle such issue in that module. Thoughts?

wenjoy avatar Jun 19 '20 02:06 wenjoy

I think it needs to be handled in sql_builder, and if the value ends with "", it can be very violent to directly add a "" at the end

manyuanrong avatar Jun 22 '20 02:06 manyuanrong

I've raised a pull request to fix this in sql-builder https://github.com/manyuanrong/sql-builder/pull/11

ccouzens avatar Sep 23 '20 21:09 ccouzens