kylefarris / node-querybuilder

Node QueryBuilder Adapter for Node.js (tags: nodejs, node, mysql, active record, activerecord, querybuilder, query builder)
49 stars 19 forks source link

[mysql] like does not escape apostrophe #30

Closed Flamenco closed 6 years ago

Flamenco commented 6 years ago

The apostrophe is not escaped in this case:

let titleQuery = "it's"
qb.like('s.title', titleQuery, 'both')

The produced SQL has invalid syntax

AND `s`.`title` LIKE '%it's%'

The documentation states:

All fields are escaped automatically, no exceptions.

kylefarris commented 6 years ago

Yikes, I'll right a test and get it fixed for v2. Thanks for the bug report.

kylefarris commented 6 years ago

This is officially fixed in the v2 branch. Beta should be out soon.