activerecord 8.0.0.beta1 → 8.0.0.rc2
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 +102 -2
- data/lib/active_record/association_relation.rb +1 -0
- data/lib/active_record/associations/association.rb +9 -5
- data/lib/active_record/associations/has_many_through_association.rb +7 -1
- data/lib/active_record/associations.rb +28 -16
- 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/callbacks.rb +1 -1
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +26 -8
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +4 -5
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +6 -1
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +8 -2
- data/lib/active_record/connection_adapters/abstract_adapter.rb +0 -1
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +8 -4
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +2 -4
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +1 -10
- 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 +11 -10
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +12 -10
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +1 -1
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +0 -2
- data/lib/active_record/connection_adapters.rb +0 -56
- data/lib/active_record/core.rb +43 -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/enum.rb +9 -22
- data/lib/active_record/fixtures.rb +0 -1
- data/lib/active_record/gem_version.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/marshalling.rb +4 -1
- data/lib/active_record/migration/command_recorder.rb +5 -5
- data/lib/active_record/migration.rb +0 -5
- data/lib/active_record/model_schema.rb +2 -3
- data/lib/active_record/query_cache.rb +0 -4
- data/lib/active_record/query_logs.rb +5 -11
- data/lib/active_record/querying.rb +2 -2
- data/lib/active_record/railtie.rb +2 -25
- data/lib/active_record/railties/databases.rake +2 -17
- data/lib/active_record/reflection.rb +14 -19
- data/lib/active_record/relation/calculations.rb +24 -28
- data/lib/active_record/relation/predicate_builder.rb +8 -0
- data/lib/active_record/relation/query_methods.rb +76 -38
- data/lib/active_record/relation.rb +8 -1
- data/lib/active_record/result.rb +10 -9
- data/lib/active_record/table_metadata.rb +1 -3
- data/lib/active_record/tasks/database_tasks.rb +26 -34
- data/lib/active_record/testing/query_assertions.rb +2 -2
- data/lib/active_record.rb +0 -45
- data/lib/arel/table.rb +3 -7
- data/lib/arel/visitors/sqlite.rb +25 -0
- metadata +9 -10
- data/lib/active_record/relation/record_fetch_warning.rb +0 -52
data/lib/active_record.rb
CHANGED
@@ -268,14 +268,6 @@ module ActiveRecord
|
|
268
268
|
singleton_class.attr_accessor :reading_role
|
269
269
|
self.reading_role = :reading
|
270
270
|
|
271
|
-
def self.legacy_connection_handling=(_)
|
272
|
-
raise ArgumentError, <<~MSG.squish
|
273
|
-
The `legacy_connection_handling` setter was deprecated in 7.0 and removed in 7.1,
|
274
|
-
but is still defined in your configuration. Please remove this call as it no longer
|
275
|
-
has any effect."
|
276
|
-
MSG
|
277
|
-
end
|
278
|
-
|
279
271
|
##
|
280
272
|
# :singleton-method: async_query_executor
|
281
273
|
# Sets the async_query_executor for an application. By default the thread pool executor
|
@@ -359,29 +351,6 @@ module ActiveRecord
|
|
359
351
|
singleton_class.attr_accessor :run_after_transaction_callbacks_in_order_defined
|
360
352
|
self.run_after_transaction_callbacks_in_order_defined = false
|
361
353
|
|
362
|
-
def self.commit_transaction_on_non_local_return
|
363
|
-
ActiveRecord.deprecator.warn <<-WARNING.squish
|
364
|
-
`Rails.application.config.active_record.commit_transaction_on_non_local_return`
|
365
|
-
is deprecated and will be removed in Rails 8.0.
|
366
|
-
WARNING
|
367
|
-
end
|
368
|
-
|
369
|
-
def self.commit_transaction_on_non_local_return=(value)
|
370
|
-
ActiveRecord.deprecator.warn <<-WARNING.squish
|
371
|
-
`Rails.application.config.active_record.commit_transaction_on_non_local_return`
|
372
|
-
is deprecated and will be removed in Rails 8.0.
|
373
|
-
WARNING
|
374
|
-
end
|
375
|
-
|
376
|
-
##
|
377
|
-
# :singleton-method: warn_on_records_fetched_greater_than
|
378
|
-
# Specify a threshold for the size of query result sets. If the number of
|
379
|
-
# records in the set exceeds the threshold, a warning is logged. This can
|
380
|
-
# be used to identify queries which load thousands of records and
|
381
|
-
# potentially cause memory bloat.
|
382
|
-
singleton_class.attr_accessor :warn_on_records_fetched_greater_than
|
383
|
-
self.warn_on_records_fetched_greater_than = false
|
384
|
-
|
385
354
|
singleton_class.attr_accessor :application_record_class
|
386
355
|
self.application_record_class = nil
|
387
356
|
|
@@ -459,20 +428,6 @@ module ActiveRecord
|
|
459
428
|
singleton_class.attr_accessor :verify_foreign_keys_for_fixtures
|
460
429
|
self.verify_foreign_keys_for_fixtures = false
|
461
430
|
|
462
|
-
def self.allow_deprecated_singular_associations_name
|
463
|
-
ActiveRecord.deprecator.warn <<-WARNING.squish
|
464
|
-
`Rails.application.config.active_record.allow_deprecated_singular_associations_name`
|
465
|
-
is deprecated and will be removed in Rails 8.0.
|
466
|
-
WARNING
|
467
|
-
end
|
468
|
-
|
469
|
-
def self.allow_deprecated_singular_associations_name=(value)
|
470
|
-
ActiveRecord.deprecator.warn <<-WARNING.squish
|
471
|
-
`Rails.application.config.active_record.allow_deprecated_singular_associations_name`
|
472
|
-
is deprecated and will be removed in Rails 8.0.
|
473
|
-
WARNING
|
474
|
-
end
|
475
|
-
|
476
431
|
singleton_class.attr_accessor :query_transformers
|
477
432
|
self.query_transformers = []
|
478
433
|
|
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/visitors/sqlite.rb
CHANGED
@@ -33,6 +33,31 @@ module Arel # :nodoc: all
|
|
33
33
|
collector << " IS NOT "
|
34
34
|
visit o.right, collector
|
35
35
|
end
|
36
|
+
|
37
|
+
# Queries used in UNION should not be wrapped by parentheses,
|
38
|
+
# because it is an invalid syntax in SQLite.
|
39
|
+
def infix_value_with_paren(o, collector, value, suppress_parens = false)
|
40
|
+
collector << "( " unless suppress_parens
|
41
|
+
|
42
|
+
left = o.left.is_a?(Nodes::Grouping) ? o.left.expr : o.left
|
43
|
+
collector = if left.class == o.class
|
44
|
+
infix_value_with_paren(left, collector, value, true)
|
45
|
+
else
|
46
|
+
grouping_parentheses left, collector, false
|
47
|
+
end
|
48
|
+
|
49
|
+
collector << value
|
50
|
+
|
51
|
+
right = o.right.is_a?(Nodes::Grouping) ? o.right.expr : o.right
|
52
|
+
collector = if right.class == o.class
|
53
|
+
infix_value_with_paren(right, collector, value, true)
|
54
|
+
else
|
55
|
+
grouping_parentheses right, collector, false
|
56
|
+
end
|
57
|
+
|
58
|
+
collector << " )" unless suppress_parens
|
59
|
+
collector
|
60
|
+
end
|
36
61
|
end
|
37
62
|
end
|
38
63
|
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: 8.0.0.
|
4
|
+
version: 8.0.0.rc2
|
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-10-30 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: 8.0.0.
|
19
|
+
version: 8.0.0.rc2
|
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: 8.0.0.
|
26
|
+
version: 8.0.0.rc2
|
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: 8.0.0.
|
33
|
+
version: 8.0.0.rc2
|
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: 8.0.0.
|
40
|
+
version: 8.0.0.rc2
|
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/v8.0.0.
|
480
|
-
documentation_uri: https://api.rubyonrails.org/v8.0.0.
|
478
|
+
changelog_uri: https://github.com/rails/rails/blob/v8.0.0.rc2/activerecord/CHANGELOG.md
|
479
|
+
documentation_uri: https://api.rubyonrails.org/v8.0.0.rc2/
|
481
480
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
482
|
-
source_code_uri: https://github.com/rails/rails/tree/v8.0.0.
|
481
|
+
source_code_uri: https://github.com/rails/rails/tree/v8.0.0.rc2/activerecord
|
483
482
|
rubygems_mfa_required: 'true'
|
484
483
|
post_install_message:
|
485
484
|
rdoc_options:
|
@@ -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 model.logger && ActiveRecord.warn_on_records_fetched_greater_than
|
24
|
-
if records.length > ActiveRecord.warn_on_records_fetched_greater_than
|
25
|
-
model.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
|