balderdashy / waterline-sequel

A SQL generator for use in Waterline Adapters
MIT License
16 stars 61 forks source link

Bug: `contains: "%"` always matches every row, but it shouldn't #33

Closed dmarcelino closed 9 years ago

dmarcelino commented 9 years ago

*SQL adapters contains' criteria acts as a LIKE '%[value]%' but it shouldn't as the documentation does not imply contains is meant to take SQL syntax:

From the documentation:

'contains'

A shorthand for pattern matching both sides of a string. Will return records where the value contains the string anywhere inside of it.

Given contains is meant to be consistent across adapters, the value should be escaped in SQL adapters. For example Model.find().where({name: {contains: "%"}} should become select * where name like '%\%%'.

The issue seems to lie in the criteria processor here: https://github.com/balderdashy/waterline-sequel/blob/master/sequel/lib/criteriaProcessor.js#L623-L645

Originally raised by @cspotcode in balderdashy/waterline#899 (click for details and discussion).

sailsbot commented 9 years ago

Thanks for posting, @dmarcelino. I'm a repo bot-- nice to meet you!

It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:

Thanks so much for your help!

AmirTugi commented 7 years ago

@dmarcelino Has there been any progress regarding this issue? This is still an issue on waterline-sequel 0.6.4

dmarcelino commented 7 years ago

Hey @AmirTugi, you'll have to ask someone from the sails team.

AmirTugi commented 7 years ago

So I sat around trying to to see where the issue starts from, and I realized the problem was actually not a problem in the code, but rather I did not encode the URL I used to retrieve the data by SailsJS blueprints routes. So after I encoded it, everything worked like a charm. Thanks anyway