mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Refactor query methods not to depend on internal DEFAULT_VALUES
constant
This constant is no longer useful since 58df9a452f
.
This commit is contained in:
parent
0c2bb3485c
commit
f854b46aba
1 changed files with 4 additions and 15 deletions
|
@ -90,7 +90,7 @@ module ActiveRecord
|
||||||
when *Relation::SINGLE_VALUE_METHODS
|
when *Relation::SINGLE_VALUE_METHODS
|
||||||
["#{name}_value", name == :create_with ? "FROZEN_EMPTY_HASH" : "nil"]
|
["#{name}_value", name == :create_with ? "FROZEN_EMPTY_HASH" : "nil"]
|
||||||
when *Relation::CLAUSE_METHODS
|
when *Relation::CLAUSE_METHODS
|
||||||
["#{name}_clause", "DEFAULT_VALUES[:#{name}]"]
|
["#{name}_clause", name == :from ? "Relation::FromClause.empty" : "Relation::WhereClause.empty"]
|
||||||
end
|
end
|
||||||
|
|
||||||
class_eval <<-CODE, __FILE__, __LINE__ + 1
|
class_eval <<-CODE, __FILE__, __LINE__ + 1
|
||||||
|
@ -447,7 +447,7 @@ module ActiveRecord
|
||||||
raise ArgumentError, "Called unscope() with invalid unscoping argument ':#{scope}'. Valid arguments are :#{VALID_UNSCOPING_VALUES.to_a.join(", :")}."
|
raise ArgumentError, "Called unscope() with invalid unscoping argument ':#{scope}'. Valid arguments are :#{VALID_UNSCOPING_VALUES.to_a.join(", :")}."
|
||||||
end
|
end
|
||||||
assert_mutability!
|
assert_mutability!
|
||||||
@values[scope] = DEFAULT_VALUES[scope]
|
@values.delete(scope)
|
||||||
when Hash
|
when Hash
|
||||||
scope.each do |key, target_value|
|
scope.each do |key, target_value|
|
||||||
if key != :where
|
if key != :where
|
||||||
|
@ -1361,8 +1361,8 @@ module ActiveRecord
|
||||||
def structurally_incompatible_values_for_or(other)
|
def structurally_incompatible_values_for_or(other)
|
||||||
values = other.values
|
values = other.values
|
||||||
STRUCTURAL_OR_METHODS.reject do |method|
|
STRUCTURAL_OR_METHODS.reject do |method|
|
||||||
default = DEFAULT_VALUES[method]
|
v1, v2 = @values[method], values[method]
|
||||||
@values.fetch(method, default) == values.fetch(method, default)
|
v1 == v2 || (!v1 || v1.empty?) && (!v2 || v2.empty?)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1370,16 +1370,5 @@ module ActiveRecord
|
||||||
@where_clause_factory ||= Relation::WhereClauseFactory.new(klass, predicate_builder)
|
@where_clause_factory ||= Relation::WhereClauseFactory.new(klass, predicate_builder)
|
||||||
end
|
end
|
||||||
alias having_clause_factory where_clause_factory
|
alias having_clause_factory where_clause_factory
|
||||||
|
|
||||||
DEFAULT_VALUES = {
|
|
||||||
create_with: FROZEN_EMPTY_HASH,
|
|
||||||
where: Relation::WhereClause.empty,
|
|
||||||
having: Relation::WhereClause.empty,
|
|
||||||
from: Relation::FromClause.empty
|
|
||||||
}
|
|
||||||
|
|
||||||
Relation::MULTI_VALUE_METHODS.each do |value|
|
|
||||||
DEFAULT_VALUES[value] ||= FROZEN_EMPTY_ARRAY
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue