Skip to content

Commit 0f77935

Browse files
Merge pull request rails#46330 from jonathanhefner/active_record-deprecator
Add `ActiveRecord.deprecator`
2 parents 73388a2 + 682353e commit 0f77935

33 files changed

+72
-48
lines changed

activerecord/lib/active_record.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
require "yaml"
3131

3232
require "active_record/version"
33+
require "active_record/deprecator"
3334
require "active_model/attribute_set"
3435
require "active_record/errors"
3536

@@ -337,14 +338,14 @@ def self.global_executor_concurrency # :nodoc:
337338
self.dump_schemas = :schema_search_path
338339

339340
def self.suppress_multiple_database_warning
340-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
341+
ActiveRecord.deprecator.warn(<<-MSG.squish)
341342
config.active_record.suppress_multiple_database_warning is deprecated and will be removed in Rails 7.2.
342343
It no longer has any effect and should be removed from the configuration file.
343344
MSG
344345
end
345346

346347
def self.suppress_multiple_database_warning=(value)
347-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
348+
ActiveRecord.deprecator.warn(<<-MSG.squish)
348349
config.active_record.suppress_multiple_database_warning= is deprecated and will be removed in Rails 7.2.
349350
It no longer has any effect and should be removed from the configuration file.
350351
MSG

activerecord/lib/active_record/attribute_methods/dirty.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@ module Dirty
2929

3030
module ClassMethods
3131
def partial_writes
32-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
32+
ActiveRecord.deprecator.warn(<<-MSG.squish)
3333
ActiveRecord::Base.partial_writes is deprecated and will be removed in Rails 7.1.
3434
Use `partial_updates` and `partial_inserts` instead.
3535
MSG
3636
partial_updates && partial_inserts
3737
end
3838

3939
def partial_writes?
40-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
40+
ActiveRecord.deprecator.warn(<<-MSG.squish)
4141
`ActiveRecord::Base.partial_writes?` is deprecated and will be removed in Rails 7.1.
4242
Use `partial_updates?` and `partial_inserts?` instead.
4343
MSG
4444
partial_updates? && partial_inserts?
4545
end
4646

4747
def partial_writes=(value)
48-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
48+
ActiveRecord.deprecator.warn(<<-MSG.squish)
4949
`ActiveRecord::Base.partial_writes=` is deprecated and will be removed in Rails 7.1.
5050
Use `partial_updates=` and `partial_inserts=` instead.
5151
MSG

activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def connection_pool_names # :nodoc:
9393
end
9494

9595
def all_connection_pools
96-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
96+
ActiveRecord.deprecator.warn(<<-MSG.squish)
9797
The `all_connection_pools` method is deprecated in favor of `connection_pool_list`.
9898
Call `connection_pool_list(:all)` to get the same behavior as `all_connection_pools`.
9999
MSG
@@ -288,7 +288,7 @@ def deprecation_for_pool_handling(method)
288288
end
289289

290290
if roles.flatten.uniq.count > 1
291-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
291+
ActiveRecord.deprecator.warn(<<-MSG.squish)
292292
`#{method}` currently only applies to connection pools in the current
293293
role (`#{ActiveRecord::Base.current_role}`). In Rails 7.1, this method
294294
will apply to all known pools, regardless of role. To affect only those

activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def connection_class # :nodoc:
182182
pool_config.connection_class
183183
end
184184
alias :connection_klass :connection_class
185-
deprecate :connection_klass
185+
deprecate :connection_klass, deprecator: ActiveRecord.deprecator
186186

187187
# Returns true if there is an open connection being used for the current thread.
188188
#

activerecord/lib/active_record/connection_adapters/abstract/quoting.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def lookup_cast_type(sql_type)
221221
end
222222

223223
def warn_quote_duration_deprecated
224-
ActiveSupport::Deprecation.warn(<<~MSG)
224+
ActiveRecord.deprecator.warn(<<~MSG)
225225
Using ActiveSupport::Duration as an interpolated bind parameter in a SQL
226226
string template is deprecated. To avoid this warning, you should explicitly
227227
convert the duration to a more specific database type. For example, if you

activerecord/lib/active_record/connection_adapters/abstract/transaction.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def within_new_transaction(isolation: nil, joinable: true)
487487
if !completed && transaction.written_indirectly
488488
# This is the case that was missed in the 6.1 deprecation, so we have to
489489
# do it now
490-
ActiveSupport::Deprecation.warn(<<~EOW)
490+
ActiveRecord.deprecator.warn(<<~EOW)
491491
Using `return`, `break` or `throw` to exit a transaction block is
492492
deprecated without replacement. If the `throw` came from
493493
`Timeout.timeout(duration)`, pass an exception class as a second

activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def translate_exception(exception, message:, sql:, binds:)
172172
end
173173

174174
def default_prepared_statements
175-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
175+
ActiveRecord.deprecator.warn(<<-MSG.squish)
176176
The default value of `prepared_statements` for the mysql2 adapter will be changed from +false+ to +true+ in Rails 7.2.
177177
MSG
178178
false

activerecord/lib/active_record/connection_handling.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def flush_idle_connections!(role = nil)
330330

331331
private
332332
def deprecation_for_delegation(method)
333-
ActiveSupport::Deprecation.warn(<<-MSG.squish)
333+
ActiveRecord.deprecator.warn(<<-MSG.squish)
334334
Calling `ActiveRecord::Base.#{method} is deprecated. Please
335335
call the method directly on the connection handler; for
336336
example: `ActiveRecord::Base.connection_handler.#{method}`.

activerecord/lib/active_record/core.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,15 @@ def find_by!(*args) # :nodoc:
309309
).each do |attr|
310310
module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
311311
def #{attr}
312-
ActiveSupport::Deprecation.warn(<<~MSG)
312+
ActiveRecord.deprecator.warn(<<~MSG)
313313
ActiveRecord::Base.#{attr} is deprecated and will be removed in Rails 7.1.
314314
Use `ActiveRecord.#{attr}` instead.
315315
MSG
316316
ActiveRecord.#{attr}
317317
end
318318
319319
def #{attr}=(value)
320-
ActiveSupport::Deprecation.warn(<<~MSG)
320+
ActiveRecord.deprecator.warn(<<~MSG)
321321
ActiveRecord::Base.#{attr}= is deprecated and will be removed in Rails 7.1.
322322
Use `ActiveRecord.#{attr}=` instead.
323323
MSG

activerecord/lib/active_record/database_configurations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def initialize(configurations = {})
4545
def configs_for(env_name: nil, name: nil, include_replicas: false, include_hidden: false)
4646
if include_replicas
4747
include_hidden = include_replicas
48-
ActiveSupport::Deprecation.warn("The kwarg `include_replicas` is deprecated in favor of `include_hidden`. When `include_hidden` is passed, configurations with `replica: true` or `database_tasks: false` will be returned. `include_replicas` will be removed in Rails 7.1.")
48+
ActiveRecord.deprecator.warn("The kwarg `include_replicas` is deprecated in favor of `include_hidden`. When `include_hidden` is passed, configurations with `replica: true` or `database_tasks: false` will be returned. `include_replicas` will be removed in Rails 7.1.")
4949
end
5050

5151
env_name ||= default_env if name

0 commit comments

Comments
 (0)