activerecord 7.2.2 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +239 -878
- data/README.rdoc +1 -1
- data/lib/active_record/association_relation.rb +1 -0
- data/lib/active_record/associations/association.rb +34 -10
- data/lib/active_record/associations/builder/association.rb +7 -6
- data/lib/active_record/associations/collection_association.rb +10 -8
- data/lib/active_record/associations/disable_joins_association_scope.rb +1 -1
- data/lib/active_record/associations/has_many_through_association.rb +3 -2
- data/lib/active_record/associations/preloader/association.rb +2 -2
- data/lib/active_record/associations/singular_association.rb +8 -3
- data/lib/active_record/associations.rb +34 -4
- data/lib/active_record/asynchronous_queries_tracker.rb +28 -24
- data/lib/active_record/attribute_methods/primary_key.rb +2 -7
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +2 -12
- data/lib/active_record/attribute_methods.rb +1 -1
- data/lib/active_record/autosave_association.rb +69 -27
- data/lib/active_record/connection_adapters/abstract/connection_handler.rb +16 -10
- data/lib/active_record/connection_adapters/abstract/connection_pool/queue.rb +0 -1
- data/lib/active_record/connection_adapters/abstract/connection_pool/reaper.rb +0 -1
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +0 -9
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +90 -43
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +8 -2
- data/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +4 -5
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +7 -2
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +33 -6
- data/lib/active_record/connection_adapters/abstract/transaction.rb +15 -5
- data/lib/active_record/connection_adapters/abstract_adapter.rb +24 -26
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +21 -39
- data/lib/active_record/connection_adapters/mysql/quoting.rb +0 -8
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +2 -8
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +43 -45
- data/lib/active_record/connection_adapters/mysql2/database_statements.rb +42 -98
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +1 -8
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +64 -42
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +10 -0
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +2 -4
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +1 -11
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +6 -12
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +2 -1
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +59 -16
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +45 -95
- data/lib/active_record/connection_adapters/schema_cache.rb +1 -3
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +76 -100
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +0 -6
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +13 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +8 -1
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +53 -12
- data/lib/active_record/connection_adapters/trilogy/database_statements.rb +37 -67
- data/lib/active_record/connection_adapters/trilogy_adapter.rb +0 -17
- data/lib/active_record/connection_adapters.rb +0 -56
- data/lib/active_record/connection_handling.rb +22 -0
- data/lib/active_record/core.rb +18 -14
- data/lib/active_record/database_configurations/database_config.rb +4 -0
- data/lib/active_record/database_configurations/hash_config.rb +8 -0
- data/lib/active_record/encryption/config.rb +3 -1
- data/lib/active_record/encryption/encryptable_record.rb +4 -4
- data/lib/active_record/encryption/encrypted_attribute_type.rb +10 -1
- data/lib/active_record/encryption/encryptor.rb +15 -8
- data/lib/active_record/encryption/extended_deterministic_queries.rb +4 -2
- data/lib/active_record/encryption/scheme.rb +8 -1
- data/lib/active_record/enum.rb +9 -22
- data/lib/active_record/errors.rb +13 -5
- data/lib/active_record/fixtures.rb +0 -2
- data/lib/active_record/future_result.rb +14 -10
- data/lib/active_record/gem_version.rb +3 -3
- data/lib/active_record/insert_all.rb +1 -1
- data/lib/active_record/locking/optimistic.rb +1 -1
- data/lib/active_record/log_subscriber.rb +5 -11
- data/lib/active_record/migration/command_recorder.rb +27 -10
- data/lib/active_record/migration/compatibility.rb +5 -2
- data/lib/active_record/migration.rb +35 -38
- data/lib/active_record/model_schema.rb +3 -4
- data/lib/active_record/nested_attributes.rb +4 -6
- data/lib/active_record/persistence.rb +128 -130
- data/lib/active_record/query_logs.rb +102 -50
- data/lib/active_record/query_logs_formatter.rb +17 -28
- data/lib/active_record/querying.rb +8 -8
- data/lib/active_record/railtie.rb +2 -26
- data/lib/active_record/railties/databases.rake +2 -17
- data/lib/active_record/reflection.rb +18 -21
- data/lib/active_record/relation/batches/batch_enumerator.rb +4 -3
- data/lib/active_record/relation/batches.rb +132 -72
- data/lib/active_record/relation/calculations.rb +40 -39
- data/lib/active_record/relation/delegation.rb +25 -14
- data/lib/active_record/relation/finder_methods.rb +18 -18
- data/lib/active_record/relation/merger.rb +8 -8
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +1 -1
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +4 -3
- data/lib/active_record/relation/predicate_builder.rb +13 -0
- data/lib/active_record/relation/query_methods.rb +115 -65
- data/lib/active_record/relation/spawn_methods.rb +1 -1
- data/lib/active_record/relation.rb +79 -61
- data/lib/active_record/result.rb +66 -4
- data/lib/active_record/sanitization.rb +7 -6
- data/lib/active_record/schema_dumper.rb +5 -0
- data/lib/active_record/schema_migration.rb +2 -1
- data/lib/active_record/scoping/named.rb +5 -2
- data/lib/active_record/statement_cache.rb +12 -12
- data/lib/active_record/store.rb +7 -3
- data/lib/active_record/table_metadata.rb +1 -3
- data/lib/active_record/tasks/database_tasks.rb +48 -47
- data/lib/active_record/tasks/mysql_database_tasks.rb +0 -2
- data/lib/active_record/tasks/sqlite_database_tasks.rb +2 -2
- data/lib/active_record/test_fixtures.rb +12 -0
- data/lib/active_record/token_for.rb +1 -1
- data/lib/active_record/validations/uniqueness.rb +8 -8
- data/lib/active_record.rb +15 -45
- data/lib/arel/collectors/bind.rb +1 -1
- data/lib/arel/table.rb +3 -7
- metadata +11 -12
- data/lib/active_record/relation/record_fetch_warning.rb +0 -52
|
@@ -178,22 +178,9 @@ module ActiveRecord
|
|
|
178
178
|
dump_db_configs = []
|
|
179
179
|
|
|
180
180
|
each_current_configuration(env) do |db_config|
|
|
181
|
-
|
|
182
|
-
begin
|
|
183
|
-
database_initialized = migration_connection_pool.schema_migration.table_exists?
|
|
184
|
-
rescue ActiveRecord::NoDatabaseError
|
|
185
|
-
create(db_config)
|
|
186
|
-
retry
|
|
187
|
-
end
|
|
181
|
+
database_initialized = initialize_database(db_config)
|
|
188
182
|
|
|
189
|
-
|
|
190
|
-
if File.exist?(schema_dump_path(db_config))
|
|
191
|
-
load_schema(db_config, ActiveRecord.schema_format, nil)
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
seed = true
|
|
195
|
-
end
|
|
196
|
-
end
|
|
183
|
+
seed = true if database_initialized && db_config.seeds?
|
|
197
184
|
end
|
|
198
185
|
|
|
199
186
|
each_current_environment(env) do |environment|
|
|
@@ -253,12 +240,33 @@ module ActiveRecord
|
|
|
253
240
|
end
|
|
254
241
|
end
|
|
255
242
|
|
|
256
|
-
def
|
|
243
|
+
def migrate_all
|
|
244
|
+
db_configs = ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env)
|
|
245
|
+
db_configs.each { |db_config| initialize_database(db_config) }
|
|
246
|
+
|
|
247
|
+
if db_configs.size == 1 && db_configs.first.primary?
|
|
248
|
+
ActiveRecord::Tasks::DatabaseTasks.migrate(skip_initialize: true)
|
|
249
|
+
else
|
|
250
|
+
mapped_versions = ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions
|
|
251
|
+
|
|
252
|
+
mapped_versions.sort.each do |version, db_configs|
|
|
253
|
+
db_configs.each do |db_config|
|
|
254
|
+
ActiveRecord::Tasks::DatabaseTasks.with_temporary_connection(db_config) do
|
|
255
|
+
ActiveRecord::Tasks::DatabaseTasks.migrate(version, skip_initialize: true)
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def migrate(version = nil, skip_initialize: false)
|
|
257
263
|
scope = ENV["SCOPE"]
|
|
258
264
|
verbose_was, Migration.verbose = Migration.verbose, verbose?
|
|
259
265
|
|
|
260
266
|
check_target_version
|
|
261
267
|
|
|
268
|
+
initialize_database(migration_connection_pool.db_config) unless skip_initialize
|
|
269
|
+
|
|
262
270
|
migration_connection_pool.migration_context.migrate(target_version) do |migration|
|
|
263
271
|
if version.blank?
|
|
264
272
|
scope.blank? || scope == migration.scope
|
|
@@ -457,26 +465,10 @@ module ActiveRecord
|
|
|
457
465
|
end
|
|
458
466
|
end
|
|
459
467
|
|
|
460
|
-
def cache_dump_filename(
|
|
461
|
-
|
|
462
|
-
schema_cache_path ||
|
|
463
|
-
|
|
464
|
-
schema_cache_env ||
|
|
465
|
-
db_config_or_name.default_schema_cache_path(ActiveRecord::Tasks::DatabaseTasks.db_dir)
|
|
466
|
-
else
|
|
467
|
-
ActiveRecord.deprecator.warn(<<~MSG.squish)
|
|
468
|
-
Passing a database name to `cache_dump_filename` is deprecated and will be removed in Rails 8.0. Pass a
|
|
469
|
-
`ActiveRecord::DatabaseConfigurations::DatabaseConfig` object instead.
|
|
470
|
-
MSG
|
|
471
|
-
|
|
472
|
-
filename = if ActiveRecord::Base.configurations.primary?(db_config_or_name)
|
|
473
|
-
"schema_cache.yml"
|
|
474
|
-
else
|
|
475
|
-
"#{db_config_or_name}_schema_cache.yml"
|
|
476
|
-
end
|
|
477
|
-
|
|
478
|
-
schema_cache_path || schema_cache_env || File.join(ActiveRecord::Tasks::DatabaseTasks.db_dir, filename)
|
|
479
|
-
end
|
|
468
|
+
def cache_dump_filename(db_config, schema_cache_path: nil)
|
|
469
|
+
schema_cache_path ||
|
|
470
|
+
db_config.schema_cache_path ||
|
|
471
|
+
db_config.default_schema_cache_path(ActiveRecord::Tasks::DatabaseTasks.db_dir)
|
|
480
472
|
end
|
|
481
473
|
|
|
482
474
|
def load_schema_current(format = ActiveRecord.schema_format, file = nil, environment = env)
|
|
@@ -547,17 +539,6 @@ module ActiveRecord
|
|
|
547
539
|
end
|
|
548
540
|
|
|
549
541
|
private
|
|
550
|
-
def schema_cache_env
|
|
551
|
-
if ENV["SCHEMA_CACHE"]
|
|
552
|
-
ActiveRecord.deprecator.warn(<<~MSG.squish)
|
|
553
|
-
Setting `ENV["SCHEMA_CACHE"]` is deprecated and will be removed in Rails 8.0.
|
|
554
|
-
Configure the `:schema_cache_path` in the database configuration instead.
|
|
555
|
-
MSG
|
|
556
|
-
|
|
557
|
-
nil
|
|
558
|
-
end
|
|
559
|
-
end
|
|
560
|
-
|
|
561
542
|
def with_temporary_pool(db_config, clobber: false)
|
|
562
543
|
original_db_config = migration_class.connection_db_config
|
|
563
544
|
pool = migration_class.connection_handler.establish_connection(db_config, clobber: clobber)
|
|
@@ -667,6 +648,26 @@ module ActiveRecord
|
|
|
667
648
|
rescue ActiveRecord::NoDatabaseError
|
|
668
649
|
end
|
|
669
650
|
end
|
|
651
|
+
|
|
652
|
+
def initialize_database(db_config)
|
|
653
|
+
with_temporary_pool(db_config) do
|
|
654
|
+
begin
|
|
655
|
+
database_already_initialized = migration_connection_pool.schema_migration.table_exists?
|
|
656
|
+
rescue ActiveRecord::NoDatabaseError
|
|
657
|
+
create(db_config)
|
|
658
|
+
retry
|
|
659
|
+
end
|
|
660
|
+
|
|
661
|
+
unless database_already_initialized
|
|
662
|
+
schema_dump_path = schema_dump_path(db_config)
|
|
663
|
+
if schema_dump_path && File.exist?(schema_dump_path)
|
|
664
|
+
load_schema(db_config, ActiveRecord.schema_format, nil)
|
|
665
|
+
end
|
|
666
|
+
end
|
|
667
|
+
|
|
668
|
+
!database_already_initialized
|
|
669
|
+
end
|
|
670
|
+
end
|
|
670
671
|
end
|
|
671
672
|
end
|
|
672
673
|
end
|
|
@@ -50,9 +50,9 @@ module ActiveRecord
|
|
|
50
50
|
if ignore_tables.any?
|
|
51
51
|
ignore_tables = connection.data_sources.select { |table| ignore_tables.any? { |pattern| pattern === table } }
|
|
52
52
|
condition = ignore_tables.map { |table| connection.quote(table) }.join(", ")
|
|
53
|
-
args << "SELECT sql FROM sqlite_master WHERE tbl_name NOT IN (#{condition}) ORDER BY tbl_name, type DESC, name"
|
|
53
|
+
args << "SELECT sql || ';' FROM sqlite_master WHERE tbl_name NOT IN (#{condition}) ORDER BY tbl_name, type DESC, name"
|
|
54
54
|
else
|
|
55
|
-
args << ".schema"
|
|
55
|
+
args << ".schema --nosys"
|
|
56
56
|
end
|
|
57
57
|
run_cmd("sqlite3", args, filename)
|
|
58
58
|
end
|
|
@@ -137,12 +137,15 @@ module ActiveRecord
|
|
|
137
137
|
invalidate_already_loaded_fixtures
|
|
138
138
|
@loaded_fixtures = load_fixtures(config)
|
|
139
139
|
end
|
|
140
|
+
setup_asynchronous_queries_session
|
|
140
141
|
|
|
141
142
|
# Instantiate fixtures for every test if requested.
|
|
142
143
|
instantiate_fixtures if use_instantiated_fixtures
|
|
143
144
|
end
|
|
144
145
|
|
|
145
146
|
def teardown_fixtures
|
|
147
|
+
teardown_asynchronous_queries_session
|
|
148
|
+
|
|
146
149
|
# Rollback changes if a transaction is active.
|
|
147
150
|
if run_in_transaction?
|
|
148
151
|
teardown_transactional_fixtures
|
|
@@ -154,6 +157,14 @@ module ActiveRecord
|
|
|
154
157
|
ActiveRecord::Base.connection_handler.clear_active_connections!(:all)
|
|
155
158
|
end
|
|
156
159
|
|
|
160
|
+
def setup_asynchronous_queries_session
|
|
161
|
+
@_async_queries_session = ActiveRecord::Base.asynchronous_queries_tracker.start_session
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def teardown_asynchronous_queries_session
|
|
165
|
+
ActiveRecord::Base.asynchronous_queries_tracker.finalize_session(true) if @_async_queries_session
|
|
166
|
+
end
|
|
167
|
+
|
|
157
168
|
def invalidate_already_loaded_fixtures
|
|
158
169
|
@@already_loaded_fixtures.clear
|
|
159
170
|
end
|
|
@@ -190,6 +201,7 @@ module ActiveRecord
|
|
|
190
201
|
|
|
191
202
|
def teardown_transactional_fixtures
|
|
192
203
|
ActiveSupport::Notifications.unsubscribe(@connection_subscriber) if @connection_subscriber
|
|
204
|
+
|
|
193
205
|
unless @fixture_connection_pools.map(&:unpin_connection!).all?
|
|
194
206
|
# Something caused the transaction to be committed or rolled back
|
|
195
207
|
# We can no longer trust the database is in a clean state.
|
|
@@ -40,7 +40,7 @@ module ActiveRecord
|
|
|
40
40
|
# +nil+ if the token is invalid or the record was not found.
|
|
41
41
|
def find_by_token_for(purpose, token)
|
|
42
42
|
raise UnknownPrimaryKey.new(self) unless model.primary_key
|
|
43
|
-
model.token_definitions.fetch(purpose).resolve_token(token) { |id| find_by(model.primary_key => id) }
|
|
43
|
+
model.token_definitions.fetch(purpose).resolve_token(token) { |id| find_by(model.primary_key => [id]) }
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
# Finds a record using a given +token+ for a predefined +purpose+. Raises
|
|
@@ -54,17 +54,17 @@ module ActiveRecord
|
|
|
54
54
|
private
|
|
55
55
|
# The check for an existing value should be run from a class that
|
|
56
56
|
# isn't abstract. This means working down from the current class
|
|
57
|
-
# (self), to the first non-abstract class.
|
|
58
|
-
# their subclasses, we have to build the hierarchy between self and
|
|
59
|
-
# the record's class.
|
|
57
|
+
# (self), to the first non-abstract class.
|
|
60
58
|
def find_finder_class_for(record)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
current_class = record.class
|
|
60
|
+
found_class = nil
|
|
61
|
+
loop do
|
|
62
|
+
found_class = current_class unless current_class.abstract_class?
|
|
63
|
+
break if current_class == @klass
|
|
64
|
+
current_class = current_class.superclass
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
found_class
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
def validation_needed?(klass, record, attribute)
|
data/lib/active_record.rb
CHANGED
|
@@ -29,6 +29,7 @@ require "active_support/ordered_options"
|
|
|
29
29
|
require "active_model"
|
|
30
30
|
require "arel"
|
|
31
31
|
require "yaml"
|
|
32
|
+
require "zlib"
|
|
32
33
|
|
|
33
34
|
require "active_record/version"
|
|
34
35
|
require "active_record/deprecator"
|
|
@@ -196,6 +197,20 @@ module ActiveRecord
|
|
|
196
197
|
singleton_class.attr_accessor :schema_cache_ignored_tables
|
|
197
198
|
self.schema_cache_ignored_tables = []
|
|
198
199
|
|
|
200
|
+
# Checks to see if the +table_name+ is ignored by checking
|
|
201
|
+
# against the +schema_cache_ignored_tables+ option.
|
|
202
|
+
#
|
|
203
|
+
# ActiveRecord.schema_cache_ignored_table?(:developers)
|
|
204
|
+
#
|
|
205
|
+
def self.schema_cache_ignored_table?(table_name)
|
|
206
|
+
ActiveRecord.schema_cache_ignored_tables.any? do |ignored|
|
|
207
|
+
ignored === table_name
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
singleton_class.attr_accessor :database_cli
|
|
212
|
+
self.database_cli = { postgresql: "psql", mysql: %w[mysql mysql5], sqlite: "sqlite3" }
|
|
213
|
+
|
|
199
214
|
singleton_class.attr_reader :default_timezone
|
|
200
215
|
|
|
201
216
|
# Determines whether to use Time.utc (using :utc) or Time.local (using :local) when pulling
|
|
@@ -253,14 +268,6 @@ module ActiveRecord
|
|
|
253
268
|
singleton_class.attr_accessor :reading_role
|
|
254
269
|
self.reading_role = :reading
|
|
255
270
|
|
|
256
|
-
def self.legacy_connection_handling=(_)
|
|
257
|
-
raise ArgumentError, <<~MSG.squish
|
|
258
|
-
The `legacy_connection_handling` setter was deprecated in 7.0 and removed in 7.1,
|
|
259
|
-
but is still defined in your configuration. Please remove this call as it no longer
|
|
260
|
-
has any effect."
|
|
261
|
-
MSG
|
|
262
|
-
end
|
|
263
|
-
|
|
264
271
|
##
|
|
265
272
|
# :singleton-method: async_query_executor
|
|
266
273
|
# Sets the async_query_executor for an application. By default the thread pool executor
|
|
@@ -344,29 +351,6 @@ module ActiveRecord
|
|
|
344
351
|
singleton_class.attr_accessor :run_after_transaction_callbacks_in_order_defined
|
|
345
352
|
self.run_after_transaction_callbacks_in_order_defined = false
|
|
346
353
|
|
|
347
|
-
def self.commit_transaction_on_non_local_return
|
|
348
|
-
ActiveRecord.deprecator.warn <<-WARNING.squish
|
|
349
|
-
`Rails.application.config.active_record.commit_transaction_on_non_local_return`
|
|
350
|
-
is deprecated and will be removed in Rails 8.0.
|
|
351
|
-
WARNING
|
|
352
|
-
end
|
|
353
|
-
|
|
354
|
-
def self.commit_transaction_on_non_local_return=(value)
|
|
355
|
-
ActiveRecord.deprecator.warn <<-WARNING.squish
|
|
356
|
-
`Rails.application.config.active_record.commit_transaction_on_non_local_return`
|
|
357
|
-
is deprecated and will be removed in Rails 8.0.
|
|
358
|
-
WARNING
|
|
359
|
-
end
|
|
360
|
-
|
|
361
|
-
##
|
|
362
|
-
# :singleton-method: warn_on_records_fetched_greater_than
|
|
363
|
-
# Specify a threshold for the size of query result sets. If the number of
|
|
364
|
-
# records in the set exceeds the threshold, a warning is logged. This can
|
|
365
|
-
# be used to identify queries which load thousands of records and
|
|
366
|
-
# potentially cause memory bloat.
|
|
367
|
-
singleton_class.attr_accessor :warn_on_records_fetched_greater_than
|
|
368
|
-
self.warn_on_records_fetched_greater_than = false
|
|
369
|
-
|
|
370
354
|
singleton_class.attr_accessor :application_record_class
|
|
371
355
|
self.application_record_class = nil
|
|
372
356
|
|
|
@@ -444,20 +428,6 @@ module ActiveRecord
|
|
|
444
428
|
singleton_class.attr_accessor :verify_foreign_keys_for_fixtures
|
|
445
429
|
self.verify_foreign_keys_for_fixtures = false
|
|
446
430
|
|
|
447
|
-
def self.allow_deprecated_singular_associations_name
|
|
448
|
-
ActiveRecord.deprecator.warn <<-WARNING.squish
|
|
449
|
-
`Rails.application.config.active_record.allow_deprecated_singular_associations_name`
|
|
450
|
-
is deprecated and will be removed in Rails 8.0.
|
|
451
|
-
WARNING
|
|
452
|
-
end
|
|
453
|
-
|
|
454
|
-
def self.allow_deprecated_singular_associations_name=(value)
|
|
455
|
-
ActiveRecord.deprecator.warn <<-WARNING.squish
|
|
456
|
-
`Rails.application.config.active_record.allow_deprecated_singular_associations_name`
|
|
457
|
-
is deprecated and will be removed in Rails 8.0.
|
|
458
|
-
WARNING
|
|
459
|
-
end
|
|
460
|
-
|
|
461
431
|
singleton_class.attr_accessor :query_transformers
|
|
462
432
|
self.query_transformers = []
|
|
463
433
|
|
data/lib/arel/collectors/bind.rb
CHANGED
data/lib/arel/table.rb
CHANGED
|
@@ -12,13 +12,9 @@ module Arel # :nodoc: all
|
|
|
12
12
|
attr_reader :table_alias
|
|
13
13
|
|
|
14
14
|
def initialize(name, as: nil, klass: nil, type_caster: klass&.type_caster)
|
|
15
|
-
|
|
16
|
-
case name
|
|
17
|
-
when Symbol then name.to_s
|
|
18
|
-
else
|
|
19
|
-
name
|
|
20
|
-
end
|
|
15
|
+
name = name.name if name.is_a?(Symbol)
|
|
21
16
|
|
|
17
|
+
@name = name
|
|
22
18
|
@klass = klass
|
|
23
19
|
@type_caster = type_caster
|
|
24
20
|
|
|
@@ -84,7 +80,7 @@ module Arel # :nodoc: all
|
|
|
84
80
|
end
|
|
85
81
|
|
|
86
82
|
def [](name, table = self)
|
|
87
|
-
name = name.
|
|
83
|
+
name = name.name if name.is_a?(Symbol)
|
|
88
84
|
name = @klass.attribute_aliases[name] || name if @klass
|
|
89
85
|
Attribute.new(table, name)
|
|
90
86
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 8.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
11
|
+
date: 2024-11-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -16,28 +16,28 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - '='
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 8.0.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - '='
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 8.0.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: activemodel
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - '='
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 8.0.0
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - '='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: 8.0.0
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: timeout
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -318,7 +318,6 @@ files:
|
|
|
318
318
|
- lib/active_record/relation/predicate_builder/relation_handler.rb
|
|
319
319
|
- lib/active_record/relation/query_attribute.rb
|
|
320
320
|
- lib/active_record/relation/query_methods.rb
|
|
321
|
-
- lib/active_record/relation/record_fetch_warning.rb
|
|
322
321
|
- lib/active_record/relation/spawn_methods.rb
|
|
323
322
|
- lib/active_record/relation/where_clause.rb
|
|
324
323
|
- lib/active_record/result.rb
|
|
@@ -476,10 +475,10 @@ licenses:
|
|
|
476
475
|
- MIT
|
|
477
476
|
metadata:
|
|
478
477
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
|
479
|
-
changelog_uri: https://github.com/rails/rails/blob/
|
|
480
|
-
documentation_uri: https://api.rubyonrails.org/
|
|
478
|
+
changelog_uri: https://github.com/rails/rails/blob/v8.0.0/activerecord/CHANGELOG.md
|
|
479
|
+
documentation_uri: https://api.rubyonrails.org/v8.0.0/
|
|
481
480
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
|
482
|
-
source_code_uri: https://github.com/rails/rails/tree/
|
|
481
|
+
source_code_uri: https://github.com/rails/rails/tree/v8.0.0/activerecord
|
|
483
482
|
rubygems_mfa_required: 'true'
|
|
484
483
|
post_install_message:
|
|
485
484
|
rdoc_options:
|
|
@@ -491,14 +490,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
491
490
|
requirements:
|
|
492
491
|
- - ">="
|
|
493
492
|
- !ruby/object:Gem::Version
|
|
494
|
-
version: 3.
|
|
493
|
+
version: 3.2.0
|
|
495
494
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
496
495
|
requirements:
|
|
497
496
|
- - ">="
|
|
498
497
|
- !ruby/object:Gem::Version
|
|
499
498
|
version: '0'
|
|
500
499
|
requirements: []
|
|
501
|
-
rubygems_version: 3.5.
|
|
500
|
+
rubygems_version: 3.5.22
|
|
502
501
|
signing_key:
|
|
503
502
|
specification_version: 4
|
|
504
503
|
summary: Object-relational mapper framework (part of Rails).
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module ActiveRecord
|
|
4
|
-
class Relation
|
|
5
|
-
module RecordFetchWarning
|
|
6
|
-
# Deprecated: subscribe to sql.active_record notifications and
|
|
7
|
-
# access the row count field to detect large result set sizes.
|
|
8
|
-
#
|
|
9
|
-
# When this module is prepended to ActiveRecord::Relation and
|
|
10
|
-
# +config.active_record.warn_on_records_fetched_greater_than+ is
|
|
11
|
-
# set to an integer, if the number of records a query returns is
|
|
12
|
-
# greater than the value of +warn_on_records_fetched_greater_than+,
|
|
13
|
-
# a warning is logged. This allows for the detection of queries that
|
|
14
|
-
# return a large number of records, which could cause memory bloat.
|
|
15
|
-
#
|
|
16
|
-
# In most cases, fetching large number of records can be performed
|
|
17
|
-
# efficiently using the ActiveRecord::Batches methods.
|
|
18
|
-
# See ActiveRecord::Batches for more information.
|
|
19
|
-
def exec_queries
|
|
20
|
-
QueryRegistry.reset
|
|
21
|
-
|
|
22
|
-
super.tap do |records|
|
|
23
|
-
if logger && ActiveRecord.warn_on_records_fetched_greater_than
|
|
24
|
-
if records.length > ActiveRecord.warn_on_records_fetched_greater_than
|
|
25
|
-
logger.warn "Query fetched #{records.size} #{@klass} records: #{QueryRegistry.queries.join(";")}"
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# :stopdoc:
|
|
32
|
-
ActiveSupport::Notifications.subscribe("sql.active_record") do |*, payload|
|
|
33
|
-
QueryRegistry.queries << payload[:sql]
|
|
34
|
-
end
|
|
35
|
-
# :startdoc:
|
|
36
|
-
|
|
37
|
-
module QueryRegistry # :nodoc:
|
|
38
|
-
extend self
|
|
39
|
-
|
|
40
|
-
def queries
|
|
41
|
-
ActiveSupport::IsolatedExecutionState[:active_record_query_registry] ||= []
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def reset
|
|
45
|
-
queries.clear
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
ActiveRecord::Relation.prepend ActiveRecord::Relation::RecordFetchWarning
|