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

Merge pull request #25986 from kamipo/remove_unnecessary_methods_for_null_relation

Remove unnecessary methods for `NullRelation`
This commit is contained in:
Sean Griffin 2016-08-01 13:37:22 -04:00 committed by GitHub
commit c205e3fca3

View file

@ -1,9 +1,5 @@
module ActiveRecord
module NullRelation # :nodoc:
def exec_queries
@records = [].freeze
end
def pluck(*column_names)
[]
end
@ -20,10 +16,6 @@ module ActiveRecord
0
end
def size
calculate :size, nil
end
def empty?
true
end
@ -48,28 +40,8 @@ module ActiveRecord
""
end
def count(*)
calculate :count, nil
end
def sum(*)
calculate :sum, nil
end
def average(*)
calculate :average, nil
end
def minimum(*)
calculate :minimum, nil
end
def maximum(*)
calculate :maximum, nil
end
def calculate(operation, _column_name)
if [:count, :sum, :size].include? operation
if [:count, :sum].include? operation
group_values.any? ? Hash.new : 0
elsif [:average, :minimum, :maximum].include?(operation) && group_values.any?
Hash.new
@ -85,5 +57,11 @@ module ActiveRecord
def or(other)
other.spawn
end
private
def exec_queries
@records = [].freeze
end
end
end