aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation.rb
diff options
context:
space:
mode:
authorEileen M. Uchitelle <eileencodes@users.noreply.github.com>2019-03-22 08:13:39 -0400
committerGitHub <noreply@github.com>2019-03-22 08:13:39 -0400
commitf40860800c231ecd1daef6cf6b5a8a8eda76478d (patch)
tree0fed20acbc7ebc1b71d29de434a3a0ca78741936 /activerecord/lib/active_record/relation.rb
parent0a0f115031b64b5335fa88543c40df4194dfb428 (diff)
parentf41825809cf3d27f98467bd7bc005e5d6ed94828 (diff)
downloadrails-f40860800c231ecd1daef6cf6b5a8a8eda76478d.tar.gz
rails-f40860800c231ecd1daef6cf6b5a8a8eda76478d.tar.bz2
rails-f40860800c231ecd1daef6cf6b5a8a8eda76478d.zip
Merge pull request #35617 from mattyoho/add-annotation-support-to-relations
Add support for annotating queries generated by ActiveRecord::Relation with SQL comments
Diffstat (limited to 'activerecord/lib/active_record/relation.rb')
-rw-r--r--activerecord/lib/active_record/relation.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 6d954a2b2e..36c2422d84 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -5,7 +5,7 @@ module ActiveRecord
class Relation
MULTI_VALUE_METHODS = [:includes, :eager_load, :preload, :select, :group,
:order, :joins, :left_outer_joins, :references,
- :extending, :unscope, :optimizer_hints]
+ :extending, :unscope, :optimizer_hints, :annotate]
SINGLE_VALUE_METHODS = [:limit, :offset, :lock, :readonly, :reordering,
:reverse_order, :distinct, :create_with, :skip_query_cache]
@@ -389,6 +389,8 @@ module ActiveRecord
stmt.set Arel.sql(klass.sanitize_sql_for_assignment(updates, table.name))
end
+ stmt.comment(*arel.comment_node.values) if arel.comment_node
+
@klass.connection.update stmt, "#{@klass} Update All"
end
@@ -504,6 +506,7 @@ module ActiveRecord
stmt.offset(arel.offset)
stmt.order(*arel.orders)
stmt.wheres = arel.constraints
+ stmt.comment(*arel.comment_node.values) if arel.comment_node
affected = @klass.connection.delete(stmt, "#{@klass} Destroy")