1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

There is no need to check null_relation? in empty_scope?

`values[:extending]` includes `NullRelation` if `null_relation?`.
This commit is contained in:
Ryuta Kamizono 2019-04-06 12:00:17 +09:00
parent 56b4fdb52b
commit 0856f7c744
3 changed files with 8 additions and 1 deletions

View file

@ -689,7 +689,7 @@ module ActiveRecord
end
def empty_scope? # :nodoc:
!null_relation? && @values == klass.unscoped.values
@values == klass.unscoped.values
end
def has_limit_or_offset? # :nodoc:

View file

@ -101,6 +101,9 @@ module ActiveRecord
relation.merge!(relation)
assert_predicate relation, :empty_scope?
assert_not_predicate NullPost.all, :empty_scope?
assert_not_predicate FirstPost.all, :empty_scope?
end
def test_bad_constants_raise_errors

View file

@ -203,6 +203,10 @@ end
class SubAbstractStiPost < AbstractStiPost; end
class NullPost < Post
default_scope { none }
end
class FirstPost < ActiveRecord::Base
self.inheritance_column = :disabled
self.table_name = "posts"