Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Like and NotLike condition builders #147

Merged
merged 1 commit into from
Sep 27, 2018
Merged

Add Like and NotLike condition builders #147

merged 1 commit into from
Sep 27, 2018

Conversation

mccolljr
Copy link
Contributor

There's currently another PR with similar purpose open, but in my opinion it adds a lot of complexity that is unnecessary for such a lightweight feature. I have added Like and NotLike methods to the top-level namespace, both of which accept an optional ESCAPE parameter. In case you're skeptical (I was, as I had not used this before and assumed it went at the end of a condition), Postgres, MySQL, and Microsoft SQL all support the ESCAPE keyword, and it can be used inside a condition such as the following:

# matches movies whose name starts with '50%' and were released after 2000
SELECT * FROM `movies` WHERE `title` LIKE "50#%%" ESCAPE "#" and `release_year` > 2000 

(view on sqlfiddle: http://sqlfiddle.com/#!9/74b26e/1/0)

@taylorchu
Copy link
Contributor

lgtm

@taylorchu taylorchu merged commit 37261c0 into gocraft:master Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants