diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-07 16:52:55 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-07 16:52:55 -0200 |
commit | 8d02afeaee8993bd0fde69687fdd9bf30921e805 (patch) | |
tree | 93cfbc3e5b18379c69abe6befa2bb3e78e542e86 /activerecord/lib | |
parent | 7b50dc5316f1db83b2d138a12bb0b0ab5ea90a33 (diff) | |
download | rails-8d02afeaee8993bd0fde69687fdd9bf30921e805.tar.gz rails-8d02afeaee8993bd0fde69687fdd9bf30921e805.tar.bz2 rails-8d02afeaee8993bd0fde69687fdd9bf30921e805.zip |
Rollback where.like and where.not_like
The real win with these chain methods is where.not, that takes care of
different scenarios in a graceful way, for instance when the given value
is nil.
where("author.id != ?", author_to_ignore.id)
where.not("author.id", author_to_ignore.id)
Both where.like and where.not_like compared to the SQL versions doesn't
seem to give us that much:
Post.where("title LIKE 'ruby on%'")
Post.where.like(title: 'ruby on%'")
Post.where("title NOT LIKE 'ruby on%'")
Post.where.not_like(title: 'ruby on%'")
Thus Rails is adding where.not, but not where.like/not_like and others.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 9484092430..f6d106f304 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -47,32 +47,6 @@ module ActiveRecord @scope.where_values += where_value @scope end - - # Returns a new relation expressing WHERE + LIKE condition - # according to the conditions provided as a hash in the arguments. - # - # Book.where.like(title: "Rails%") - # # SELECT * FROM books WHERE title LIKE 'Rails%' - def like(opts, *rest) - where_value = @scope.send(:build_where, opts, rest).map do |rel| - Arel::Nodes::Matches.new(rel.left, rel.right) - end - @scope.where_values += where_value - @scope - end - - # Returns a new relation expressing WHERE + NOT LIKE condition - # according to the conditions provided as a hash in the arguments. - # - # Conference.where.not_like(name: "%Kaigi") - # # SELECT * FROM conferences WHERE name NOT LIKE '%Kaigi' - def not_like(opts, *rest) - where_value = @scope.send(:build_where, opts, rest).map do |rel| - Arel::Nodes::DoesNotMatch.new(rel.left, rel.right) - end - @scope.where_values += where_value - @scope - end end Relation::MULTI_VALUE_METHODS.each do |name| |