aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/spawn_methods.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2010-12-31 10:43:42 +0000
committerJon Leighton <j@jonathanleighton.com>2010-12-31 20:00:44 +0000
commit62b084f80759300f10a4e5c4235bf1d13693a7d3 (patch)
tree6eda5936f42ce5a14404edd8aa4823587b2bb3c4 /activerecord/lib/active_record/relation/spawn_methods.rb
parent2bf31868033c50d71d6d68c1ddad67147908adc4 (diff)
downloadrails-62b084f80759300f10a4e5c4235bf1d13693a7d3.tar.gz
rails-62b084f80759300f10a4e5c4235bf1d13693a7d3.tar.bz2
rails-62b084f80759300f10a4e5c4235bf1d13693a7d3.zip
Specify the STI type condition using SQL IN rather than a whole load of ORs. Required a fix to ActiveRecord::Relation#merge for properly merging create_with_value. This also fixes a situation where the type condition was appearing twice in the resultant SQL query.
Diffstat (limited to 'activerecord/lib/active_record/relation/spawn_methods.rb')
-rw-r--r--activerecord/lib/active_record/relation/spawn_methods.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb
index 5acf3ec83a..e1f7fa2949 100644
--- a/activerecord/lib/active_record/relation/spawn_methods.rb
+++ b/activerecord/lib/active_record/relation/spawn_methods.rb
@@ -46,13 +46,17 @@ module ActiveRecord
merged_relation.where_values = merged_wheres
- (Relation::SINGLE_VALUE_METHODS - [:lock]).each do |method|
+ (Relation::SINGLE_VALUE_METHODS - [:lock, :create_with]).each do |method|
value = r.send(:"#{method}_value")
merged_relation.send(:"#{method}_value=", value) unless value.nil?
end
merged_relation.lock_value = r.lock_value unless merged_relation.lock_value
+ if r.create_with_value
+ merged_relation.create_with_value = (merged_relation.create_with_value || {}).merge(r.create_with_value)
+ end
+
# Apply scope extension modules
merged_relation.send :apply_modules, r.extensions