Skip to content

Commit fc9ed11

Browse files
Deprecate config.active_record.warn_on_records_fetched_greater_than (rails#51007)
* Deprecate config.active_record.warn_on_records_fetched_greater_than * Review changes Co-authored-by: Rafael Mendonça França <[email protected]> --------- Co-authored-by: Jason Nochlin <[email protected]> Co-authored-by: Rafael Mendonça França <[email protected]>
1 parent f8ffd46 commit fc9ed11

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

activerecord/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
* Deprecate `config.active_record.warn_on_records_fetched_greater_than` now that `sql.active_record`
2+
notification includes `:row_count` field.
3+
4+
*Jason Nochlin*
5+
16
* Fix an issue where `ActiveRecord::Encryption` configurations are not ready before the loading
27
of Active Record models, when an application is eager loaded. As a result, encrypted attributes
38
could be misconfigured in some cases.

activerecord/lib/active_record/railtie.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ class Railtie < Rails::Railtie # :nodoc:
223223

224224
initializer "active_record.warn_on_records_fetched_greater_than" do
225225
if config.active_record.warn_on_records_fetched_greater_than
226+
ActiveRecord.deprecator.warn <<~MSG.squish
227+
`config.active_record.warn_on_records_fetched_greater_than` is deprecated and will be
228+
removed in Rails 7.3.
229+
Please subscribe to `sql.active_record` notifications and access the row count field to
230+
detect large result set sizes.
231+
MSG
226232
ActiveSupport.on_load(:active_record) do
227233
require "active_record/relation/record_fetch_warning"
228234
end

activerecord/lib/active_record/relation/record_fetch_warning.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
module ActiveRecord
44
class Relation
55
module RecordFetchWarning
6+
# Deprecated: subscribe to sql.active_record notifications and
7+
# access the row count field to detect large result set sizes.
8+
#
69
# When this module is prepended to ActiveRecord::Relation and
710
# +config.active_record.warn_on_records_fetched_greater_than+ is
811
# set to an integer, if the number of records a query returns is

0 commit comments

Comments
 (0)