Open yibn2008 opened 6 years ago
I just tracked down a bug in my code base that was caused by the similar issue: by default, STRINGS ARE NOT ESCAPED!!!
console.log(squel.update()
.table("t")
.set("name", "foo'bar")
.toString())
// Prints:
// UPDATE t SET name = 'foo'bar'
Note that the string is not escaped.
This is an extremely surprising and dangerous default!
IMPORTANT: This issue may cause SQL injection:
Problem
for example:
expect:
actual:
Workaround
Use
sqlstring
will escape string value correctly: