Skip to content

Commit b458ed8

Browse files
authored
Merge pull request rails#54278 from zzak/re-54244
Make payload[:name] of eager loading `sql.active_record` to "#{model.name} Eager Load".
2 parents 916f984 + d713105 commit b458ed8

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

activerecord/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* Change the payload name of `sql.active_record` notification for eager
2+
loading from "SQL" to "#{model.name} Eager Load".
3+
4+
*zzak*
5+
16
* Enable automatically retrying idempotent `#exists?` queries on connection
27
errors.
38

activerecord/lib/active_record/relation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ def exec_main_query(async: false)
14521452
else
14531453
relation = join_dependency.apply_column_aliases(relation)
14541454
@_join_dependency = join_dependency
1455-
c.select_all(relation.arel, "SQL", async: async)
1455+
c.select_all(relation.arel, "#{model.name} Eager Load", async: async)
14561456
end
14571457
end
14581458
end

activerecord/test/cases/instrumentation_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ def test_payload_name_on_update_all
4343
assert_equal "Book Update All", notification.payload[:name]
4444
end
4545

46+
def test_payload_name_on_eager_load
47+
notification = capture_notifications("sql.active_record") { Book.eager_load(:author).to_a }
48+
assert_equal "Book Eager Load", notification.first.payload[:name]
49+
end
50+
4651
def test_payload_name_on_destroy
4752
book = Book.create(name: "test book")
4853

activerecord/test/cases/relation/load_async_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_eager_loading_query
163163
status = {}
164164

165165
subscriber = ActiveSupport::Notifications.subscribe("sql.active_record") do |event|
166-
if event.payload[:name] == "SQL"
166+
if event.payload[:name] == "Post Eager Load"
167167
status[:executed] = true
168168
status[:async] = event.payload[:async]
169169
end
@@ -444,7 +444,7 @@ def test_eager_loading_query
444444

445445
status = {}
446446
subscriber = ActiveSupport::Notifications.subscribe("sql.active_record") do |event|
447-
if event.payload[:name] == "SQL"
447+
if event.payload[:name] == "Post Eager Load"
448448
status[:executed] = true
449449
status[:async] = event.payload[:async]
450450
end

0 commit comments

Comments
 (0)