{"action":"closed","issue":{"url":"https://api.github.com/repos/balderdashy/waterline-sequel/issues/33","labels_url":"https://api.github.com/repos/balderdashy/waterline-sequel/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/balderdashy/waterline-sequel/issues/33/comments","events_url":"https://api.github.com/repos/balderdashy/waterline-sequel/issues/33/events","html_url":"https://github.com/balderdashy/waterline-sequel/issues/33","id":65223758,"number":33,"title":"Bug: `contains: \"%\"` always matches every row, but it shouldn't","user":{"login":"dmarcelino","id":1280446,"avatar_url":"https://avatars.githubusercontent.com/u/1280446?v=3","gravatar_id":"","url":"https://api.github.com/users/dmarcelino","html_url":"https://github.com/dmarcelino","followers_url":"https://api.github.com/users/dmarcelino/followers","following_url":"https://api.github.com/users/dmarcelino/following{/other_user}","gists_url":"https://api.github.com/users/dmarcelino/gists{/gist_id}","starred_url":"https://api.github.com/users/dmarcelino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmarcelino/subscriptions","organizations_url":"https://api.github.com/users/dmarcelino/orgs","repos_url":"https://api.github.com/users/dmarcelino/repos","events_url":"https://api.github.com/users/dmarcelino/events{/privacy}","received_events_url":"https://api.github.com/users/dmarcelino/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/balderdashy/waterline-sequel/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/balderdashy/waterline-sequel/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-30T14:23:41Z","updated_at":"2015-09-23T17:27:36Z","closed_at":"2015-09-23T17:27:35Z","body":"*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:\r\n\r\nFrom the documentation:\r\n> #### 'contains'\r\n> A shorthand for pattern matching both sides of a string. Will return records where the value contains the string anywhere inside of it.\r\n\r\nGiven `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 '%\\%%'`.\r\n\r\nThe issue seems to lie in the criteria processor here:\r\nhttps://github.com/balderdashy/waterline-sequel/blob/master/sequel/lib/criteriaProcessor.js#L623-L645\r\n\r\nOriginally raised by @cspotcode  in balderdashy/waterline#899 (click for details and discussion)."}}