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

Case insensitivite match/regular expressions #403

Merged
merged 5 commits into from
Dec 16, 2015
Merged

Case insensitivite match/regular expressions #403

merged 5 commits into from
Dec 16, 2015

Conversation

kbrock
Copy link

@kbrock kbrock commented Dec 6, 2015

Hello all,

Postgres supports case sensitive and insensitive operations.
Regular expressions match (~) currently defaults to case sensitive but match (LIKE) defaults to case insensitive.

The goal of this PR is to

  1. Make case sensitivity explicit for match and regular expression match.
  2. Introduce predicates matches_regexp and does_not_match_regexp.

I'd like it if both regular expressions and like match defaulted to case sensitivity, but that would change the def sql generated by postgres and I assume that is discouraged.

If you would like me to make both operators default to case sensitive (or case insensitive), let me know.

/cc @matthewd @tenderlove thoughts?

Explicitly declare if this is case sensitive or not

most implementation assume case sensitive
postgres assumes case insensitive
Explicitly declare if this is case sensitive or not

currently postgres assumes case insensitive regexp
no other databases support regexps
@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @tenderlove (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@kbrock kbrock changed the title Case insensitivity Case insensitivite match/regular expressions Dec 6, 2015
@kbrock
Copy link
Author

kbrock commented Dec 16, 2015

@tenderlove I can change this to have a different Arel operator for case insensitive operators instead of booleans. Just let me know.
Happy conference going.

@kbrock
Copy link
Author

kbrock commented Dec 16, 2015

Wonder if this is a little related to #286
And ugh. Postgres uses different regular expression syntax. their SIMILAR TO uses % as a wild character, but the regular expression uses standard posix regexps .* as wild character.

I can split this PR into 2. Just ask that you state a preference around whether a) to default to case insensitive or sensitive and b) is case sensitive a boolean or a separate token?

Thanks

@tenderlove
Copy link
Member

@kbrock tbh I'm totally fine with this. I'll merge it.

tenderlove added a commit that referenced this pull request Dec 16, 2015
Case insensitivite match/regular expressions
@tenderlove tenderlove merged commit 899e842 into rails:master Dec 16, 2015
@kbrock kbrock deleted the regexp branch December 16, 2015 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants