activerecord 7.2.2.1 → 8.0.5
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +523 -677
- data/README.rdoc +2 -2
- data/lib/active_record/association_relation.rb +1 -0
- data/lib/active_record/associations/alias_tracker.rb +6 -4
- data/lib/active_record/associations/association.rb +34 -10
- data/lib/active_record/associations/belongs_to_association.rb +18 -2
- 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/join_dependency/join_association.rb +25 -27
- data/lib/active_record/associations/join_dependency.rb +2 -2
- data/lib/active_record/associations/preloader/association.rb +2 -2
- data/lib/active_record/associations/preloader/batch.rb +7 -1
- 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 +4 -8
- data/lib/active_record/attribute_methods/query.rb +34 -0
- data/lib/active_record/attribute_methods/serialization.rb +1 -1
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +2 -12
- data/lib/active_record/attribute_methods.rb +24 -19
- data/lib/active_record/attributes.rb +37 -26
- data/lib/active_record/autosave_association.rb +91 -39
- data/lib/active_record/base.rb +2 -2
- data/lib/active_record/connection_adapters/abstract/connection_handler.rb +34 -25
- 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 +55 -47
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +91 -44
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +25 -8
- 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 +12 -3
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +40 -10
- data/lib/active_record/connection_adapters/abstract/transaction.rb +15 -5
- data/lib/active_record/connection_adapters/abstract_adapter.rb +92 -70
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +35 -46
- data/lib/active_record/connection_adapters/mysql/quoting.rb +7 -9
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +2 -8
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +50 -45
- data/lib/active_record/connection_adapters/mysql2/database_statements.rb +84 -94
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +9 -9
- data/lib/active_record/connection_adapters/pool_config.rb +7 -7
- data/lib/active_record/connection_adapters/postgresql/column.rb +4 -2
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +72 -43
- 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 +20 -24
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +3 -2
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +60 -17
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +61 -99
- data/lib/active_record/connection_adapters/schema_cache.rb +1 -3
- data/lib/active_record/connection_adapters/sqlite3/column.rb +8 -2
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +80 -100
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +13 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +0 -6
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +27 -2
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +10 -1
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +63 -17
- data/lib/active_record/connection_adapters/statement_pool.rb +4 -2
- data/lib/active_record/connection_adapters/trilogy/database_statements.rb +37 -67
- data/lib/active_record/connection_adapters/trilogy_adapter.rb +1 -18
- data/lib/active_record/connection_adapters.rb +0 -56
- data/lib/active_record/connection_handling.rb +35 -9
- data/lib/active_record/core.rb +57 -22
- data/lib/active_record/counter_cache.rb +1 -1
- data/lib/active_record/database_configurations/connection_url_resolver.rb +3 -1
- data/lib/active_record/database_configurations/database_config.rb +4 -0
- data/lib/active_record/database_configurations/hash_config.rb +16 -2
- data/lib/active_record/delegated_type.rb +18 -18
- data/lib/active_record/encryption/config.rb +3 -1
- data/lib/active_record/encryption/encryptable_record.rb +5 -5
- data/lib/active_record/encryption/encrypted_attribute_type.rb +11 -2
- data/lib/active_record/encryption/encryptor.rb +37 -28
- 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 +22 -34
- data/lib/active_record/errors.rb +16 -8
- data/lib/active_record/fixture_set/table_row.rb +19 -2
- data/lib/active_record/fixtures.rb +0 -2
- data/lib/active_record/future_result.rb +15 -9
- data/lib/active_record/gem_version.rb +4 -4
- data/lib/active_record/insert_all.rb +3 -3
- 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 +32 -12
- data/lib/active_record/migration/compatibility.rb +5 -2
- data/lib/active_record/migration.rb +40 -43
- 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 +106 -50
- data/lib/active_record/query_logs_formatter.rb +17 -28
- data/lib/active_record/querying.rb +12 -12
- data/lib/active_record/railtie.rb +4 -28
- data/lib/active_record/railties/databases.rake +11 -34
- 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 +71 -65
- data/lib/active_record/relation/delegation.rb +25 -14
- data/lib/active_record/relation/finder_methods.rb +32 -31
- data/lib/active_record/relation/merger.rb +8 -8
- data/lib/active_record/relation/predicate_builder/array_handler.rb +3 -1
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +2 -0
- 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_attribute.rb +1 -1
- data/lib/active_record/relation/query_methods.rb +121 -70
- data/lib/active_record/relation/spawn_methods.rb +7 -7
- data/lib/active_record/relation/where_clause.rb +9 -3
- data/lib/active_record/relation.rb +95 -67
- data/lib/active_record/result.rb +66 -4
- data/lib/active_record/sanitization.rb +7 -6
- data/lib/active_record/schema_dumper.rb +34 -11
- data/lib/active_record/schema_migration.rb +2 -1
- data/lib/active_record/scoping/named.rb +5 -2
- data/lib/active_record/secure_token.rb +3 -3
- data/lib/active_record/signed_id.rb +7 -6
- data/lib/active_record/statement_cache.rb +14 -14
- 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 +69 -60
- data/lib/active_record/tasks/mysql_database_tasks.rb +0 -2
- data/lib/active_record/tasks/postgresql_database_tasks.rb +9 -1
- data/lib/active_record/tasks/sqlite_database_tasks.rb +2 -2
- data/lib/active_record/test_databases.rb +1 -1
- data/lib/active_record/test_fixtures.rb +12 -0
- data/lib/active_record/token_for.rb +1 -1
- data/lib/active_record/transactions.rb +8 -7
- data/lib/active_record/type/serialized.rb +5 -0
- data/lib/active_record/validations/uniqueness.rb +8 -8
- data/lib/active_record.rb +22 -49
- data/lib/arel/collectors/bind.rb +2 -2
- data/lib/arel/collectors/sql_string.rb +1 -1
- data/lib/arel/collectors/substitute_binds.rb +2 -2
- data/lib/arel/crud.rb +2 -0
- data/lib/arel/delete_manager.rb +5 -0
- data/lib/arel/nodes/binary.rb +1 -1
- data/lib/arel/nodes/delete_statement.rb +4 -2
- data/lib/arel/nodes/node.rb +1 -1
- data/lib/arel/nodes/sql_literal.rb +1 -1
- data/lib/arel/nodes/update_statement.rb +4 -2
- data/lib/arel/predications.rb +1 -3
- data/lib/arel/select_manager.rb +6 -2
- data/lib/arel/table.rb +3 -7
- data/lib/arel/update_manager.rb +5 -0
- data/lib/arel/visitors/dot.rb +2 -0
- data/lib/arel/visitors/to_sql.rb +3 -1
- metadata +11 -15
- data/lib/active_record/relation/record_fetch_warning.rb +0 -52
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"
|
|
@@ -86,7 +87,6 @@ module ActiveRecord
|
|
|
86
87
|
autoload :Timestamp
|
|
87
88
|
autoload :TokenFor
|
|
88
89
|
autoload :TouchLater
|
|
89
|
-
autoload :Transaction
|
|
90
90
|
autoload :Transactions
|
|
91
91
|
autoload :Translation
|
|
92
92
|
autoload :Validations
|
|
@@ -108,6 +108,7 @@ module ActiveRecord
|
|
|
108
108
|
autoload :Result
|
|
109
109
|
autoload :StatementCache
|
|
110
110
|
autoload :TableMetadata
|
|
111
|
+
autoload :Transaction
|
|
111
112
|
autoload :Type
|
|
112
113
|
|
|
113
114
|
autoload_under "relation" do
|
|
@@ -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
|
|
|
@@ -384,7 +368,8 @@ module ActiveRecord
|
|
|
384
368
|
# specific) SQL statements. If :ruby, the schema is dumped as an
|
|
385
369
|
# ActiveRecord::Schema file which can be loaded into any database that
|
|
386
370
|
# supports migrations. Use :ruby if you want to have different database
|
|
387
|
-
# adapters for, e.g., your development and test environments.
|
|
371
|
+
# adapters for, e.g., your development and test environments. This can be
|
|
372
|
+
# overridden per-database in the database configuration.
|
|
388
373
|
singleton_class.attr_accessor :schema_format
|
|
389
374
|
self.schema_format = :ruby
|
|
390
375
|
|
|
@@ -444,20 +429,6 @@ module ActiveRecord
|
|
|
444
429
|
singleton_class.attr_accessor :verify_foreign_keys_for_fixtures
|
|
445
430
|
self.verify_foreign_keys_for_fixtures = false
|
|
446
431
|
|
|
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
432
|
singleton_class.attr_accessor :query_transformers
|
|
462
433
|
self.query_transformers = []
|
|
463
434
|
|
|
@@ -578,8 +549,10 @@ module ActiveRecord
|
|
|
578
549
|
open_transactions = []
|
|
579
550
|
Base.connection_handler.each_connection_pool do |pool|
|
|
580
551
|
if active_connection = pool.active_connection
|
|
581
|
-
|
|
582
|
-
|
|
552
|
+
current_transaction = active_connection.current_transaction
|
|
553
|
+
|
|
554
|
+
if current_transaction.open? && current_transaction.joinable? && !current_transaction.state.invalidated?
|
|
555
|
+
open_transactions << current_transaction
|
|
583
556
|
end
|
|
584
557
|
end
|
|
585
558
|
end
|
data/lib/arel/collectors/bind.rb
CHANGED
|
@@ -13,12 +13,12 @@ module Arel # :nodoc: all
|
|
|
13
13
|
self
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def add_bind(bind)
|
|
16
|
+
def add_bind(bind, &)
|
|
17
17
|
@binds << bind
|
|
18
18
|
self
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
def add_binds(binds, proc_for_binds = nil)
|
|
21
|
+
def add_binds(binds, proc_for_binds = nil, &)
|
|
22
22
|
@binds.concat proc_for_binds ? binds.map(&proc_for_binds) : binds
|
|
23
23
|
self
|
|
24
24
|
end
|
|
@@ -15,12 +15,12 @@ module Arel # :nodoc: all
|
|
|
15
15
|
self
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def add_bind(bind)
|
|
18
|
+
def add_bind(bind, &)
|
|
19
19
|
bind = bind.value_for_database if bind.respond_to?(:value_for_database)
|
|
20
20
|
self << quoter.quote(bind)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def add_binds(binds, proc_for_binds = nil)
|
|
23
|
+
def add_binds(binds, proc_for_binds = nil, &)
|
|
24
24
|
self << binds.map { |bind| quoter.quote(bind) }.join(", ")
|
|
25
25
|
end
|
|
26
26
|
|
data/lib/arel/crud.rb
CHANGED
|
@@ -26,6 +26,7 @@ module Arel # :nodoc: all
|
|
|
26
26
|
um.offset(offset)
|
|
27
27
|
um.order(*orders)
|
|
28
28
|
um.wheres = constraints
|
|
29
|
+
um.comment(comment)
|
|
29
30
|
um.key = key
|
|
30
31
|
|
|
31
32
|
um.group(group_values_columns) unless group_values_columns.empty?
|
|
@@ -39,6 +40,7 @@ module Arel # :nodoc: all
|
|
|
39
40
|
dm.offset(offset)
|
|
40
41
|
dm.order(*orders)
|
|
41
42
|
dm.wheres = constraints
|
|
43
|
+
dm.comment(comment)
|
|
42
44
|
dm.key = key
|
|
43
45
|
dm.group(group_values_columns) unless group_values_columns.empty?
|
|
44
46
|
dm.having(having_clause) unless having_clause.nil?
|
data/lib/arel/delete_manager.rb
CHANGED
data/lib/arel/nodes/binary.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Arel # :nodoc: all
|
|
4
4
|
module Nodes
|
|
5
5
|
class DeleteStatement < Arel::Nodes::Node
|
|
6
|
-
attr_accessor :relation, :wheres, :groups, :havings, :orders, :limit, :offset, :key
|
|
6
|
+
attr_accessor :relation, :wheres, :groups, :havings, :orders, :limit, :offset, :comment, :key
|
|
7
7
|
|
|
8
8
|
def initialize(relation = nil, wheres = [])
|
|
9
9
|
super()
|
|
@@ -14,6 +14,7 @@ module Arel # :nodoc: all
|
|
|
14
14
|
@orders = []
|
|
15
15
|
@limit = nil
|
|
16
16
|
@offset = nil
|
|
17
|
+
@comment = nil
|
|
17
18
|
@key = nil
|
|
18
19
|
end
|
|
19
20
|
|
|
@@ -24,7 +25,7 @@ module Arel # :nodoc: all
|
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
def hash
|
|
27
|
-
[self.class, @relation, @wheres, @orders, @limit, @offset, @key].hash
|
|
28
|
+
[self.class, @relation, @wheres, @orders, @limit, @offset, @comment, @key].hash
|
|
28
29
|
end
|
|
29
30
|
|
|
30
31
|
def eql?(other)
|
|
@@ -36,6 +37,7 @@ module Arel # :nodoc: all
|
|
|
36
37
|
self.havings == other.havings &&
|
|
37
38
|
self.limit == other.limit &&
|
|
38
39
|
self.offset == other.offset &&
|
|
40
|
+
self.comment == other.comment &&
|
|
39
41
|
self.key == other.key
|
|
40
42
|
end
|
|
41
43
|
alias :== :eql?
|
data/lib/arel/nodes/node.rb
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Arel # :nodoc: all
|
|
4
4
|
module Nodes
|
|
5
5
|
class UpdateStatement < Arel::Nodes::Node
|
|
6
|
-
attr_accessor :relation, :wheres, :values, :groups, :havings, :orders, :limit, :offset, :key
|
|
6
|
+
attr_accessor :relation, :wheres, :values, :groups, :havings, :orders, :limit, :offset, :comment, :key
|
|
7
7
|
|
|
8
8
|
def initialize(relation = nil)
|
|
9
9
|
super()
|
|
@@ -15,6 +15,7 @@ module Arel # :nodoc: all
|
|
|
15
15
|
@orders = []
|
|
16
16
|
@limit = nil
|
|
17
17
|
@offset = nil
|
|
18
|
+
@comment = nil
|
|
18
19
|
@key = nil
|
|
19
20
|
end
|
|
20
21
|
|
|
@@ -25,7 +26,7 @@ module Arel # :nodoc: all
|
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
def hash
|
|
28
|
-
[@relation, @wheres, @values, @orders, @limit, @offset, @key].hash
|
|
29
|
+
[@relation, @wheres, @values, @orders, @limit, @offset, @comment, @key].hash
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
def eql?(other)
|
|
@@ -38,6 +39,7 @@ module Arel # :nodoc: all
|
|
|
38
39
|
self.orders == other.orders &&
|
|
39
40
|
self.limit == other.limit &&
|
|
40
41
|
self.offset == other.offset &&
|
|
42
|
+
self.comment == other.comment &&
|
|
41
43
|
self.key == other.key
|
|
42
44
|
end
|
|
43
45
|
alias :== :eql?
|
data/lib/arel/predications.rb
CHANGED
|
@@ -231,9 +231,7 @@ module Arel # :nodoc: all
|
|
|
231
231
|
private
|
|
232
232
|
def grouping_any(method_id, others, *extras)
|
|
233
233
|
nodes = others.map { |expr| send(method_id, expr, *extras) }
|
|
234
|
-
Nodes::Grouping.new nodes
|
|
235
|
-
Nodes::Or.new([memo, node])
|
|
236
|
-
}
|
|
234
|
+
Nodes::Grouping.new Nodes::Or.new(nodes)
|
|
237
235
|
end
|
|
238
236
|
|
|
239
237
|
def grouping_all(method_id, others, *extras)
|
data/lib/arel/select_manager.rb
CHANGED
|
@@ -250,8 +250,12 @@ module Arel # :nodoc: all
|
|
|
250
250
|
end
|
|
251
251
|
|
|
252
252
|
def comment(*values)
|
|
253
|
-
|
|
254
|
-
|
|
253
|
+
if values.any?
|
|
254
|
+
@ctx.comment = Nodes::Comment.new(values)
|
|
255
|
+
self
|
|
256
|
+
else
|
|
257
|
+
@ctx.comment
|
|
258
|
+
end
|
|
255
259
|
end
|
|
256
260
|
|
|
257
261
|
private
|
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
|
data/lib/arel/update_manager.rb
CHANGED
data/lib/arel/visitors/dot.rb
CHANGED
|
@@ -153,6 +153,7 @@ module Arel # :nodoc: all
|
|
|
153
153
|
visit_edge o, "orders"
|
|
154
154
|
visit_edge o, "limit"
|
|
155
155
|
visit_edge o, "offset"
|
|
156
|
+
visit_edge o, "comment"
|
|
156
157
|
visit_edge o, "key"
|
|
157
158
|
end
|
|
158
159
|
|
|
@@ -162,6 +163,7 @@ module Arel # :nodoc: all
|
|
|
162
163
|
visit_edge o, "orders"
|
|
163
164
|
visit_edge o, "limit"
|
|
164
165
|
visit_edge o, "offset"
|
|
166
|
+
visit_edge o, "comment"
|
|
165
167
|
visit_edge o, "key"
|
|
166
168
|
end
|
|
167
169
|
|
data/lib/arel/visitors/to_sql.rb
CHANGED
|
@@ -35,6 +35,7 @@ module Arel # :nodoc: all
|
|
|
35
35
|
collect_nodes_for o.wheres, collector, " WHERE ", " AND "
|
|
36
36
|
collect_nodes_for o.orders, collector, " ORDER BY "
|
|
37
37
|
maybe_visit o.limit, collector
|
|
38
|
+
maybe_visit o.comment, collector
|
|
38
39
|
end
|
|
39
40
|
|
|
40
41
|
def visit_Arel_Nodes_UpdateStatement(o, collector)
|
|
@@ -48,6 +49,7 @@ module Arel # :nodoc: all
|
|
|
48
49
|
collect_nodes_for o.wheres, collector, " WHERE ", " AND "
|
|
49
50
|
collect_nodes_for o.orders, collector, " ORDER BY "
|
|
50
51
|
maybe_visit o.limit, collector
|
|
52
|
+
maybe_visit o.comment, collector
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
def visit_Arel_Nodes_InsertStatement(o, collector)
|
|
@@ -763,7 +765,7 @@ module Arel # :nodoc: all
|
|
|
763
765
|
|
|
764
766
|
def visit_Arel_Nodes_SqlLiteral(o, collector)
|
|
765
767
|
collector.preparable = false
|
|
766
|
-
collector.retryable
|
|
768
|
+
collector.retryable &&= o.retryable
|
|
767
769
|
collector << o.to_s
|
|
768
770
|
end
|
|
769
771
|
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 8.0.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activesupport
|
|
@@ -16,28 +15,28 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - '='
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
18
|
+
version: 8.0.5
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - '='
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
25
|
+
version: 8.0.5
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: activemodel
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
30
|
- - '='
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
32
|
+
version: 8.0.5
|
|
34
33
|
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - '='
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
39
|
+
version: 8.0.5
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
41
|
name: timeout
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -318,7 +317,6 @@ files:
|
|
|
318
317
|
- lib/active_record/relation/predicate_builder/relation_handler.rb
|
|
319
318
|
- lib/active_record/relation/query_attribute.rb
|
|
320
319
|
- lib/active_record/relation/query_methods.rb
|
|
321
|
-
- lib/active_record/relation/record_fetch_warning.rb
|
|
322
320
|
- lib/active_record/relation/spawn_methods.rb
|
|
323
321
|
- lib/active_record/relation/where_clause.rb
|
|
324
322
|
- lib/active_record/result.rb
|
|
@@ -476,12 +474,11 @@ licenses:
|
|
|
476
474
|
- MIT
|
|
477
475
|
metadata:
|
|
478
476
|
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/
|
|
477
|
+
changelog_uri: https://github.com/rails/rails/blob/v8.0.5/activerecord/CHANGELOG.md
|
|
478
|
+
documentation_uri: https://api.rubyonrails.org/v8.0.5/
|
|
481
479
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
|
482
|
-
source_code_uri: https://github.com/rails/rails/tree/
|
|
480
|
+
source_code_uri: https://github.com/rails/rails/tree/v8.0.5/activerecord
|
|
483
481
|
rubygems_mfa_required: 'true'
|
|
484
|
-
post_install_message:
|
|
485
482
|
rdoc_options:
|
|
486
483
|
- "--main"
|
|
487
484
|
- README.rdoc
|
|
@@ -491,15 +488,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
491
488
|
requirements:
|
|
492
489
|
- - ">="
|
|
493
490
|
- !ruby/object:Gem::Version
|
|
494
|
-
version: 3.
|
|
491
|
+
version: 3.2.0
|
|
495
492
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
496
493
|
requirements:
|
|
497
494
|
- - ">="
|
|
498
495
|
- !ruby/object:Gem::Version
|
|
499
496
|
version: '0'
|
|
500
497
|
requirements: []
|
|
501
|
-
rubygems_version:
|
|
502
|
-
signing_key:
|
|
498
|
+
rubygems_version: 4.0.6
|
|
503
499
|
specification_version: 4
|
|
504
500
|
summary: Object-relational mapper framework (part of Rails).
|
|
505
501
|
test_files: []
|
|
@@ -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
|