activerecord 7.1.5.2 → 7.1.6

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: 7fa4b2f9126403d6fc22dad885f81b45f0e00f9158dfbb8c0e509d212745afa4
4
- data.tar.gz: 70e8039696ed0d7b39086eff706ef31b180a7a182b823861c7ef12795fb06c67
3
+ metadata.gz: f3204f7f0cb9d1d71ab7642643724921e6c942f4f7c99beeae9ac49342f70ed7
4
+ data.tar.gz: 47c12eb7710323f64881e54ac05b70cbf6e365f7559c52579c295e6c35b2b547
5
5
  SHA512:
6
- metadata.gz: c42494b0b6a24a72010025f85a9df63a992538bc99da20a72a5312402d3b722e2275d990a4cbcbad30c44002d466b95e662e0b9e7860d6e282cb837a64e096ba
7
- data.tar.gz: b94f5d2573c1af08bd3a461a5ac0bab68e9b340f8e9e0885f682798018196ab8dd05ccea8c3ce0cf9d778910751e2e205d08d048e0b4f50f6c0c91eaa40e863b
6
+ metadata.gz: d2807f2124023b0b00d632ad9dc46c5eabd404e35fd7f75a46eb285f9875455c7444b9c059c437fef31bcc3d6694779e19cffa69ce5be81139af959ca86c8490
7
+ data.tar.gz: ea070b99aaacc7b369b8daed1256cae97f6d81f452698900c8fa25dc3f243af1900599b457b7461b2d544ff00b69e1b9b850bcf02e40b73e7581cf1abce8796f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ ## Rails 7.1.6 (October 28, 2025) ##
2
+
3
+ * Gracefully handle `Timeout.timeout` firing during connection configuration.
4
+
5
+ Use of `Timeout.timeout` could result in improperly initialized database connection.
6
+
7
+ This could lead to a partially configured connection being used, resulting in various exceptions,
8
+ the most common being with the PostgreSQLAdapter raising `undefined method `key?' for nil`
9
+ or `TypeError: wrong argument type nil (expected PG::TypeMap)`.
10
+
11
+ *Jean Boussier*
12
+
13
+ * Fix error handling during connection configuration.
14
+
15
+ Active Record wasn't properly handling errors during the connection configuration phase.
16
+ This could lead to a partially configured connection being used, resulting in various exceptions,
17
+ the most common being with the PostgreSQLAdapter raising `undefined method `key?' for nil`
18
+ or `TypeError: wrong argument type nil (expected PG::TypeMap)`.
19
+
20
+ *Jean Boussier*
21
+
22
+ * Fix prepared statements on mysql2 adapter.
23
+
24
+ *Jean Boussier*
25
+
26
+ * Fix a race condition in `ActiveRecord::Base#method_missing` when lazily defining attributes.
27
+
28
+ If multiple thread were concurrently triggering attribute definition on the same model,
29
+ it could result in a `NoMethodError` being raised.
30
+
31
+ *Jean Boussier*
32
+
33
+
1
34
  ## Rails 7.1.5.2 (August 13, 2025) ##
2
35
 
3
36
  * Call inspect on ids in RecordNotFound error
@@ -6,6 +39,7 @@
6
39
 
7
40
  *Gannon McGibbon*, *John Hawthorn*
8
41
 
42
+
9
43
  ## Rails 7.1.5.1 (December 10, 2024) ##
10
44
 
11
45
  * No changes.
@@ -138,6 +138,7 @@ module ActiveRecord
138
138
  super(attribute_names)
139
139
  @attribute_methods_generated = true
140
140
  end
141
+
141
142
  true
142
143
  end
143
144
 
@@ -480,23 +481,27 @@ module ActiveRecord
480
481
  end
481
482
 
482
483
  def method_missing(name, ...)
483
- unless self.class.attribute_methods_generated?
484
- if self.class.method_defined?(name)
485
- # The method is explicitly defined in the model, but calls a generated
486
- # method with super. So we must resume the call chain at the right setp.
487
- last_method = method(name)
488
- last_method = last_method.super_method while last_method.super_method
489
- self.class.define_attribute_methods
490
- if last_method.super_method
491
- return last_method.super_method.call(...)
492
- end
493
- elsif self.class.define_attribute_methods | self.class.generate_alias_attributes
494
- # Some attribute methods weren't generated yet, we retry the call
495
- return public_send(name, ...)
496
- end
484
+ # We can't know whether some method was defined or not because
485
+ # multiple thread might be concurrently be in this code path.
486
+ # So the first one would define the methods and the others would
487
+ # appear to already have them.
488
+ self.class.define_attribute_methods
489
+
490
+ # So in all cases we must behave as if the method was just defined.
491
+ method = begin
492
+ self.class.public_instance_method(name)
493
+ rescue NameError
494
+ nil
497
495
  end
498
496
 
499
- super
497
+ # The method might be explicitly defined in the model, but call a generated
498
+ # method with super. So we must resume the call chain at the right step.
499
+ method = method.super_method while method && !method.owner.is_a?(GeneratedAttributeMethods)
500
+ if method
501
+ method.bind_call(self, ...)
502
+ else
503
+ super
504
+ end
500
505
  end
501
506
 
502
507
  def attribute_method?(attr_name)
@@ -690,7 +690,7 @@ module ActiveRecord
690
690
 
691
691
  reset_transaction(restore: restore_transactions) do
692
692
  clear_cache!(new_connection: true)
693
- configure_connection
693
+ attempt_configure_connection
694
694
  end
695
695
  rescue => original_exception
696
696
  translated_exception = translate_exception_class(original_exception, nil, nil)
@@ -742,7 +742,7 @@ module ActiveRecord
742
742
  def reset!
743
743
  clear_cache!(new_connection: true)
744
744
  reset_transaction
745
- configure_connection
745
+ attempt_configure_connection
746
746
  end
747
747
 
748
748
  # Removes the connection from the pool and disconnect it.
@@ -778,7 +778,7 @@ module ActiveRecord
778
778
  if @unconfigured_connection
779
779
  @raw_connection = @unconfigured_connection
780
780
  @unconfigured_connection = nil
781
- configure_connection
781
+ attempt_configure_connection
782
782
  @verified = true
783
783
  return
784
784
  end
@@ -1225,6 +1225,13 @@ module ActiveRecord
1225
1225
  def configure_connection
1226
1226
  end
1227
1227
 
1228
+ def attempt_configure_connection
1229
+ configure_connection
1230
+ rescue Exception # Need to handle things such as Timeout::ExitException
1231
+ disconnect!
1232
+ raise
1233
+ end
1234
+
1228
1235
  def default_prepared_statements
1229
1236
  true
1230
1237
  end
@@ -78,7 +78,13 @@ module ActiveRecord
78
78
  else
79
79
  value.getlocal
80
80
  end
81
- when Date, Time
81
+ when Time
82
+ if default_timezone == :utc
83
+ value.utc? ? value : value.getutc
84
+ else
85
+ value.utc? ? value.getlocal : value
86
+ end
87
+ when Date
82
88
  value
83
89
  else
84
90
  super
@@ -9,8 +9,8 @@ module ActiveRecord
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 1
12
- TINY = 5
13
- PRE = "2"
12
+ TINY = 6
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  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: 7.1.5.2
4
+ version: 7.1.6
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: 7.1.5.2
18
+ version: 7.1.6
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: 7.1.5.2
25
+ version: 7.1.6
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: 7.1.5.2
32
+ version: 7.1.6
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: 7.1.5.2
39
+ version: 7.1.6
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: timeout
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -469,10 +469,10 @@ licenses:
469
469
  - MIT
470
470
  metadata:
471
471
  bug_tracker_uri: https://github.com/rails/rails/issues
472
- changelog_uri: https://github.com/rails/rails/blob/v7.1.5.2/activerecord/CHANGELOG.md
473
- documentation_uri: https://api.rubyonrails.org/v7.1.5.2/
472
+ changelog_uri: https://github.com/rails/rails/blob/v7.1.6/activerecord/CHANGELOG.md
473
+ documentation_uri: https://api.rubyonrails.org/v7.1.6/
474
474
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
475
- source_code_uri: https://github.com/rails/rails/tree/v7.1.5.2/activerecord
475
+ source_code_uri: https://github.com/rails/rails/tree/v7.1.6/activerecord
476
476
  rubygems_mfa_required: 'true'
477
477
  rdoc_options:
478
478
  - "--main"