mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
unscope now works on default_scope after 94924dc32b
This commit is contained in:
parent
09447929a0
commit
4d7080f80c
3 changed files with 9 additions and 9 deletions
|
@ -1,12 +1,15 @@
|
|||
* `.unscope` now removes conditions specified in `default_scope`.
|
||||
|
||||
*Jon Leighton*
|
||||
|
||||
* Extend ActiveRecord::Base#cache_key to take an optional list of timestamp attributes of which the highest will be used.
|
||||
|
||||
Example:
|
||||
|
||||
# last_reviewed_at will be used, if that's more recent than updated_at, or vice versa
|
||||
Person.find(5).cache_key(:updated_at, :last_reviewed_at)
|
||||
Example:
|
||||
|
||||
*DHH*
|
||||
# last_reviewed_at will be used, if that's more recent than updated_at, or vice versa
|
||||
Person.find(5).cache_key(:updated_at, :last_reviewed_at)
|
||||
|
||||
*DHH*
|
||||
|
||||
* Added ActiveRecord::Base#enum for declaring enum attributes where the values map to integers in the database, but can be queried by name.
|
||||
|
||||
|
|
|
@ -341,9 +341,6 @@ module ActiveRecord
|
|||
# User.where(name: "John", active: true).unscope(where: :name)
|
||||
# == User.where(active: true)
|
||||
#
|
||||
# This method is applied before the default_scope is applied. So the conditions
|
||||
# specified in default_scope will not be removed.
|
||||
#
|
||||
# Note that this method is more generalized than ActiveRecord::SpawnMethods#except
|
||||
# because #except will only affect a particular relation's values. It won't wipe
|
||||
# the order, grouping, etc. when that relation is merged. For example:
|
||||
|
|
|
@ -103,7 +103,7 @@ class DefaultScopingTest < ActiveRecord::TestCase
|
|||
|
||||
def test_unscope_overrides_default_scope
|
||||
expected = Developer.all.collect { |dev| [dev.name, dev.id] }
|
||||
received = Developer.order('name ASC, id DESC').unscope(:order).collect { |dev| [dev.name, dev.id] }
|
||||
received = DeveloperCalledJamis.unscope(:where).collect { |dev| [dev.name, dev.id] }
|
||||
assert_equal expected, received
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue