New method ActiveRecord::QueryMethods#unwhere #12849

wants to merge 1 commit into


None yet
2 participants

xuanxu commented Nov 11, 2013

ActiveRecord::QueryMethods#unwhere unscopes selectively existing, named where conditions.

Post.where(author: 'X', trashed: true).unwhere(:trashed) #=> WHERE `author` = 'X'
Post.where(trashed: false).unwhere(:trashed)             #=> Post.all
Post.where(active: true).where(trashed: true).unwhere    #=> Post.all

unwhere complements rewhere, and it's also a short-hand for a common feature.

Added ActiveRecord::QueryMethods#unwhere
which will unscope selectively existing, named where conditions.

rafaelfranca commented Nov 11, 2013

👎 rewhere make sense since you want to remove the where clause and add another one. If you only want to remove you already have unscope I don't think we should pollute the API with these unscope shor-hand methods.

Adding this people will want to add unlimit, unorder, unwhatever

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment