activerecord 8.1.0.rc1 → 8.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f6a8286538d4ed09b1508bed7ded4b5b40629d71cbee9467c8926968413da05
4
- data.tar.gz: ef5f9492d1efa2285bb03fdfe9d808e86ffadc768f0265257aba7d93bd5c32ad
3
+ metadata.gz: a92548efaf2245d66ddb7383470faf4182ac1d28a65f71824ba6a83c69b753fd
4
+ data.tar.gz: e019fc7a41a862fa0f0393ee6d8dd46589af1dd04ee0c9f1ddfde6716401c011
5
5
  SHA512:
6
- metadata.gz: cad145e87e54f6bfd6cc35294e4aa25471f705e08eae4497a10c75af5ff204b8205728bf41e0ff43d1a2713c712d53b56ba35fbdfdb2df8a3204edc8c9c46eef
7
- data.tar.gz: a8792d05c5c847e1c22daff04e84a662afd6847f07368fea7be61876c434f6e233f1d295c296f0c40adaa24896def1f985edc241c589489e4153554a4b15d5c7
6
+ metadata.gz: db83ab09afcb9232bc722208fd8add11064cefc613667592711d7ec21347e0933eddec2a9cdf1f4eb7f07a973a11d54a821b776da0861e320cfece6684e47a3c
7
+ data.tar.gz: 4e47cbdb388a3f4e00b55f775bf2d9397b80e1f27478e8ce00b4cb783d3ee8de72088c5303697d1080c2f5f58d6c81c053c980c984f2755d6d8224453fa684f2
data/CHANGELOG.md CHANGED
@@ -1,4 +1,26 @@
1
- ## Rails 8.1.0.rc1 (October 15, 2025) ##
1
+ ## Rails 8.1.0 (October 22, 2025) ##
2
+
3
+ * Fix SQLite3 data loss during table alterations with CASCADE foreign keys.
4
+
5
+ When altering a table in SQLite3 that is referenced by child tables with
6
+ `ON DELETE CASCADE` foreign keys, ActiveRecord would silently delete all
7
+ data from the child tables. This occurred because SQLite requires table
8
+ recreation for schema changes, and during this process the original table
9
+ is temporarily dropped, triggering CASCADE deletes on child tables.
10
+
11
+ The root cause was incorrect ordering of operations. The original code
12
+ wrapped `disable_referential_integrity` inside a transaction, but
13
+ `PRAGMA foreign_keys` cannot be modified inside a transaction in SQLite -
14
+ attempting to do so simply has no effect. This meant foreign keys remained
15
+ enabled during table recreation, causing CASCADE deletes to fire.
16
+
17
+ The fix reverses the order to follow the official SQLite 12-step ALTER TABLE
18
+ procedure: `disable_referential_integrity` now wraps the transaction instead
19
+ of being wrapped by it. This ensures foreign keys are properly disabled
20
+ before the transaction starts and re-enabled after it commits, preventing
21
+ CASCADE deletes while maintaining data integrity through atomic transactions.
22
+
23
+ *Ruy Rocha*
2
24
 
3
25
  * Add replicas to test database parallelization setup.
4
26
 
@@ -103,8 +125,6 @@
103
125
 
104
126
  *Rob Lewis*
105
127
 
106
- ## Rails 8.1.0.beta1 (September 04, 2025) ##
107
-
108
128
  * Remove deprecated `:unsigned_float` and `:unsigned_decimal` column methods for MySQL.
109
129
 
110
130
  *Rafael Mendonça França*
@@ -42,6 +42,7 @@ module ActiveRecord
42
42
  types.sort.each do |name, values|
43
43
  stream.puts " create_enum #{relation_name(name).inspect}, #{values.inspect}"
44
44
  end
45
+ stream.puts
45
46
  end
46
47
  end
47
48
  end
@@ -613,8 +613,8 @@ module ActiveRecord
613
613
  yield definition if block_given?
614
614
  end
615
615
 
616
- transaction do
617
- disable_referential_integrity do
616
+ disable_referential_integrity do
617
+ transaction do
618
618
  move_table(table_name, altered_table_name, options.merge(temporary: true))
619
619
  move_table(altered_table_name, table_name, &caller)
620
620
  end
@@ -173,9 +173,11 @@ module ActiveRecord
173
173
  prevent_writes = true if role == ActiveRecord.reading_role
174
174
 
175
175
  append_to_connected_to_stack(role: role, shard: shard, prevent_writes: prevent_writes, klasses: classes)
176
- yield
177
- ensure
178
- connected_to_stack.pop
176
+ begin
177
+ yield
178
+ ensure
179
+ connected_to_stack.pop
180
+ end
179
181
  end
180
182
 
181
183
  # Passes the block to +connected_to+ for every +shard+ the
@@ -396,11 +398,13 @@ module ActiveRecord
396
398
  prevent_writes = true if role == ActiveRecord.reading_role
397
399
 
398
400
  append_to_connected_to_stack(role: role, shard: shard, prevent_writes: prevent_writes, klasses: [self])
399
- return_value = yield
400
- return_value.load if return_value.is_a? ActiveRecord::Relation
401
- return_value
402
- ensure
403
- self.connected_to_stack.pop
401
+ begin
402
+ return_value = yield
403
+ return_value.load if return_value.is_a? ActiveRecord::Relation
404
+ return_value
405
+ ensure
406
+ self.connected_to_stack.pop
407
+ end
404
408
  end
405
409
 
406
410
  def append_to_connected_to_stack(entry)
@@ -10,7 +10,7 @@ module ActiveRecord
10
10
  MAJOR = 8
11
11
  MINOR = 1
12
12
  TINY = 0
13
- PRE = "rc1"
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -425,14 +425,10 @@ module ActiveRecord
425
425
 
426
426
  def _klass(class_name) # :nodoc:
427
427
  if active_record.name.demodulize == class_name
428
- begin
429
- compute_class("::#{class_name}")
430
- rescue NameError
431
- compute_class(class_name)
432
- end
433
- else
434
- compute_class(class_name)
428
+ return compute_class("::#{class_name}") rescue NameError
435
429
  end
430
+
431
+ compute_class(class_name)
436
432
  end
437
433
 
438
434
  def compute_class(name)
@@ -1923,7 +1923,8 @@ module ActiveRecord
1923
1923
 
1924
1924
  def build_with_expression_from_value(value, nested = false)
1925
1925
  case value
1926
- when Arel::Nodes::SqlLiteral then Arel::Nodes::Grouping.new(value)
1926
+ when Arel::Nodes::SqlLiteral, Arel::Nodes::BoundSqlLiteral
1927
+ Arel::Nodes::Grouping.new(value)
1927
1928
  when ActiveRecord::Relation
1928
1929
  if nested
1929
1930
  value.arel.ast
@@ -12,7 +12,7 @@ module ActiveRecord
12
12
 
13
13
  emit_debug_event("active_record.strict_loading_violation",
14
14
  owner: owner.name,
15
- class: reflection.klass.name,
15
+ class: reflection.polymorphic? ? nil : reflection.klass.name,
16
16
  name: reflection.name,
17
17
  )
18
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.0.rc1
4
+ version: 8.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -15,28 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 8.1.0.rc1
18
+ version: 8.1.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 8.1.0.rc1
25
+ version: 8.1.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: activemodel
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - '='
31
31
  - !ruby/object:Gem::Version
32
- version: 8.1.0.rc1
32
+ version: 8.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 8.1.0.rc1
39
+ version: 8.1.0
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: timeout
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -478,10 +478,10 @@ licenses:
478
478
  - MIT
479
479
  metadata:
480
480
  bug_tracker_uri: https://github.com/rails/rails/issues
481
- changelog_uri: https://github.com/rails/rails/blob/v8.1.0.rc1/activerecord/CHANGELOG.md
482
- documentation_uri: https://api.rubyonrails.org/v8.1.0.rc1/
481
+ changelog_uri: https://github.com/rails/rails/blob/v8.1.0/activerecord/CHANGELOG.md
482
+ documentation_uri: https://api.rubyonrails.org/v8.1.0/
483
483
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
484
- source_code_uri: https://github.com/rails/rails/tree/v8.1.0.rc1/activerecord
484
+ source_code_uri: https://github.com/rails/rails/tree/v8.1.0/activerecord
485
485
  rubygems_mfa_required: 'true'
486
486
  rdoc_options:
487
487
  - "--main"