diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-01-13 16:16:19 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-01-13 16:16:19 -0800 |
commit | bf48af53600e3e535cc4d0cfe9654c40023a7f70 (patch) | |
tree | 94db1f852c79c75d100f627615c2ba9cb8d440ec /activerecord/lib | |
parent | aec4aa1702753f29ae79787c743f6f047ad9a80d (diff) | |
parent | f1764a2de17bba07bad3ec0d88de152d8279d3bb (diff) | |
download | rails-bf48af53600e3e535cc4d0cfe9654c40023a7f70.tar.gz rails-bf48af53600e3e535cc4d0cfe9654c40023a7f70.tar.bz2 rails-bf48af53600e3e535cc4d0cfe9654c40023a7f70.zip |
Merge branch 'master' into set_binds
* master: (24 commits)
unscope should remove bind values associated with the where
reverse_order_value= is not private, so no need to send
avoid more dynamic symbols
no need to to_sym
recover from test runs that leave the database in a bad state
updates screenshot data [ci skip]
"serie" => "series"
revises a few things in the getting started guide [ci skip]
Favor canonical environment variables for secrets
removed extra comma [ci skip]
Only lookup `config.log_level` for stdlib `::Logger`. Closes #11665.
Updated Changelog to reflect removal of :dependent => :restrict
standardize on jruby_skip & rbx_skip
fix bug in becomes! when changing from base to subclass. Closes #13272.
highlight http://localhost:3000 in README.md. Closes #13643. [ci skip]
doc proc/lambda arg on inclusion validation. Closes #13689. [ci skip]
Skip Spring App Generator tests on JRuby
fixes a typo in a CHANGELOG
upgrade SDoc
fixes the Gemfile generator templates
...
Conflicts:
activerecord/test/cases/hot_compatibility_test.rb
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/enum.rb | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 10 |
3 files changed, 14 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/enum.rb b/activerecord/lib/active_record/enum.rb index 9ad718a02a..d1bc785bee 100644 --- a/activerecord/lib/active_record/enum.rb +++ b/activerecord/lib/active_record/enum.rb @@ -87,6 +87,9 @@ module ActiveRecord # def status() STATUS.key self[:status] end define_method(name) { enum_values.key self[name] } + # def status_before_type_cast() STATUS.key self[:status] end + define_method("#{name}_before_type_cast") { enum_values.key self[name] } + pairs = values.respond_to?(:each_pair) ? values.each_pair : values.each_with_index pairs.each do |value, i| enum_values[value] = i diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 4669c072a1..460fbdb3f8 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -196,7 +196,11 @@ module ActiveRecord # share the same set of attributes. def becomes!(klass) became = becomes(klass) - became.public_send("#{klass.inheritance_column}=", klass.sti_name) unless self.class.descends_from_active_record? + sti_type = nil + if !klass.descends_from_active_record? + sti_type = klass.sti_name + end + became.public_send("#{klass.inheritance_column}=", sti_type) became end diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 7571208a88..0f5fe7ea51 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -858,11 +858,11 @@ module ActiveRecord end single_val_method = Relation::SINGLE_VALUE_METHODS.include?(scope) - unscope_code = :"#{scope}_value#{'s' unless single_val_method}=" + unscope_code = "#{scope}_value#{'s' unless single_val_method}=" case scope when :order - self.send(:reverse_order_value=, false) + self.reverse_order_value = false result = [] else result = [] unless single_val_method @@ -872,17 +872,19 @@ module ActiveRecord end def where_unscoping(target_value) - target_value_sym = target_value.to_sym + target_value = target_value.to_s where_values.reject! do |rel| case rel when Arel::Nodes::In, Arel::Nodes::NotIn, Arel::Nodes::Equality, Arel::Nodes::NotEqual subrelation = (rel.left.kind_of?(Arel::Attributes::Attribute) ? rel.left : rel.right) - subrelation.name.to_sym == target_value_sym + subrelation.name == target_value else raise "unscope(where: #{target_value.inspect}) failed: unscoping #{rel.class} is unimplemented." end end + + bind_values.reject! { |col,_| col.name == target_value } end def custom_join_ast(table, joins) |