diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-01-05 00:42:10 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2018-01-05 00:53:47 +0900 |
commit | 7eaae937e661ad3026cf25f407e202779c9ea27b (patch) | |
tree | 03819be0b4e629217bf8c4b97deb97ed478db46c /activerecord/lib/active_record/relation | |
parent | c7b832730158da5372aeeff512508b2eab4e6fcc (diff) | |
download | rails-7eaae937e661ad3026cf25f407e202779c9ea27b.tar.gz rails-7eaae937e661ad3026cf25f407e202779c9ea27b.tar.bz2 rails-7eaae937e661ad3026cf25f407e202779c9ea27b.zip |
Partial revert the changing default value of `readonly_value`
This is a partial revert of #26182. There is no reason to change the
default value.
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 0296101f81..009624e194 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -378,7 +378,7 @@ module ActiveRecord if !VALID_UNSCOPING_VALUES.include?(scope) raise ArgumentError, "Called unscope() with invalid unscoping argument ':#{scope}'. Valid arguments are :#{VALID_UNSCOPING_VALUES.to_a.join(", :")}." end - set_value(scope, nil) + set_value(scope, DEFAULT_VALUES[scope]) when Hash scope.each do |key, target_value| if key != :where @@ -905,7 +905,7 @@ module ActiveRecord protected # Returns a relation value with a given name def get_value(name) # :nodoc: - @values[name] || default_value_for(name) + @values.fetch(name, DEFAULT_VALUES[name]) end # Sets the relation value with the given name @@ -1190,7 +1190,6 @@ module ActiveRecord DEFAULT_VALUES = { create_with: FROZEN_EMPTY_HASH, - readonly: false, where: Relation::WhereClause.empty, having: Relation::WhereClause.empty, from: Relation::FromClause.empty @@ -1199,15 +1198,5 @@ module ActiveRecord Relation::MULTI_VALUE_METHODS.each do |value| DEFAULT_VALUES[value] ||= FROZEN_EMPTY_ARRAY end - - Relation::SINGLE_VALUE_METHODS.each do |value| - DEFAULT_VALUES[value] = nil if DEFAULT_VALUES[value].nil? - end - - def default_value_for(name) - DEFAULT_VALUES.fetch(name) do - raise ArgumentError, "unknown relation value #{name.inspect}" - end - end end end |