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

Allow Relation.where with no arguments to be chained with new query methods not, like, and not_like #8365

Closed
wants to merge 2 commits into from

Conversation

claudiob
Copy link
Member

Similarly to #8332 this commit closes #5950 by making available three new methods not, like, and not_like that can be chained with a Relation.where with no (or nil) arguments.

The difference is that this commit follows the suggestion by José Valim #8332 (comment) to use a class and a builder, rather than a mixin, to implement WhereChain.

amatsuda and others added 2 commits November 28, 2012 23:05
examples:

  Model.where.not field: nil
  #=> "SELECT * FROM models WHERE field IS NOT NULL

  Model.where.like name: 'Jeremy%'
  #=> "SELECT * FROM models WHERE name LIKE 'Jeremy%'

this feature was originally suggested by Jeremy Kemper rails#5950 (comment)

Closes rails#5950
This feature was originally suggested by José Valim rails#8332 (comment)

The original commit fddf9c2 by Akira Matsuda enabled the methods #not, #like,
and #not_like to be chained to a Relation.where with no args.
This commit maintains the same behavior, but requires using #where before
chaining any of the previous methods, which makes chaining clearer.

Closes rails#5950
@jeremy
Copy link
Member

jeremy commented Nov 29, 2012

Thank you for implementing, @claudiob. However, let's give the original author the honors ❤️

Please do open a PR with improvements after his work is merged!

@jeremy jeremy closed this Nov 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants