activerecord 6.1.4.1 → 6.1.7.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +258 -12
  3. data/MIT-LICENSE +1 -1
  4. data/lib/active_record/associations/collection_association.rb +16 -8
  5. data/lib/active_record/associations/preloader/association.rb +1 -3
  6. data/lib/active_record/coders/yaml_column.rb +14 -2
  7. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +1 -1
  8. data/lib/active_record/connection_adapters/abstract/quoting.rb +13 -4
  9. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +4 -0
  10. data/lib/active_record/connection_adapters/mysql/database_statements.rb +2 -0
  11. data/lib/active_record/connection_adapters/mysql/schema_statements.rb +4 -1
  12. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +2 -0
  13. data/lib/active_record/connection_adapters/postgresql/quoting.rb +26 -0
  14. data/lib/active_record/connection_adapters/postgresql_adapter.rb +2 -2
  15. data/lib/active_record/connection_adapters/schema_cache.rb +34 -10
  16. data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +2 -0
  17. data/lib/active_record/connection_handling.rb +2 -2
  18. data/lib/active_record/core.rb +17 -2
  19. data/lib/active_record/database_configurations/connection_url_resolver.rb +1 -0
  20. data/lib/active_record/database_configurations/hash_config.rb +1 -1
  21. data/lib/active_record/database_configurations.rb +2 -1
  22. data/lib/active_record/gem_version.rb +2 -2
  23. data/lib/active_record/internal_metadata.rb +2 -0
  24. data/lib/active_record/legacy_yaml_adapter.rb +1 -1
  25. data/lib/active_record/migration/compatibility.rb +9 -6
  26. data/lib/active_record/model_schema.rb +1 -1
  27. data/lib/active_record/railties/databases.rake +8 -8
  28. data/lib/active_record/relation/calculations.rb +2 -2
  29. data/lib/active_record/relation/finder_methods.rb +1 -1
  30. data/lib/active_record/relation/query_methods.rb +4 -2
  31. data/lib/active_record/relation/where_clause.rb +2 -2
  32. data/lib/active_record/store.rb +6 -1
  33. data/lib/active_record/tasks/database_tasks.rb +1 -1
  34. data/lib/active_record/test_fixtures.rb +9 -5
  35. data/lib/active_record.rb +1 -1
  36. metadata +14 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfce4c7e3e72a9532c8532e7285191bd87922110c4ae68f5b614f9f760c255a8
4
- data.tar.gz: ac62553b4d11f238a2f92232b8c5146a239c9afb55a1cee10e013c9b1877b209
3
+ metadata.gz: ff58712bbebc535819e132a47df7c9f6f4be5a8f0e3fae68b7d28abdf6845747
4
+ data.tar.gz: 7b51dd493195b2951233e10f8177a56d8442588089dc60d6c6dd41afc0add8c8
5
5
  SHA512:
6
- metadata.gz: 94bdbb5e730d7975ba11ea7794ee9e7d36a3a8bbd697d95645e1492f521f16db58f75d12ddfa07c5d35a5f8c98c8971bf95a41fb9e0f5b094b34c2f2671f2fa2
7
- data.tar.gz: 9b94ac51e360a48bcc47b1c9c19a29946729bc6460b9c9f11b760f8edac7f467eb0aed05dcaa30f0baba946ffd4f6dc78f16971c8fb93051b10dd23cd22a17d8
6
+ metadata.gz: a62add4fb215dd17e2bb197b145e18284b06fadb0f7e82ab2f23cc3b0ffa63877381447bd994d367dee5f2ffd4580b5f47eb98847d221ccb72ca39f6f2549506
7
+ data.tar.gz: 4e95cde594418539534f6161b09362829543fcd755fc860305389d49651854d293a9757260ae5e824e08f7ea5997f2898e6423a9bc481c56cc7bab577f4fef14
data/CHANGELOG.md CHANGED
@@ -1,3 +1,249 @@
1
+ ## Rails 6.1.7.10 (October 23, 2024) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 6.1.7.9 (October 15, 2024) ##
7
+
8
+ * No changes.
9
+
10
+
11
+ ## Rails 6.1.7.8 (June 04, 2024) ##
12
+
13
+ * No changes.
14
+
15
+
16
+ ## Rails 6.1.7.7 (February 21, 2024) ##
17
+
18
+ * No changes.
19
+
20
+
21
+ ## Rails 6.1.7.6 (August 22, 2023) ##
22
+
23
+ * No changes.
24
+
25
+
26
+ ## Rails 6.1.7.5 (August 22, 2023) ##
27
+
28
+ * No changes.
29
+
30
+
31
+ ## Rails 6.1.7.4 (June 26, 2023) ##
32
+
33
+ * No changes.
34
+
35
+
36
+ ## Rails 6.1.7.3 (March 13, 2023) ##
37
+
38
+ * No changes.
39
+
40
+
41
+ ## Rails 6.1.7.2 (January 24, 2023) ##
42
+
43
+ * No changes.
44
+
45
+
46
+ ## Rails 6.1.7.1 (January 17, 2023) ##
47
+
48
+ * Make sanitize_as_sql_comment more strict
49
+
50
+ Though this method was likely never meant to take user input, it was
51
+ attempting sanitization. That sanitization could be bypassed with
52
+ carefully crafted input.
53
+
54
+ This commit makes the sanitization more robust by replacing any
55
+ occurrances of "/*" or "*/" with "/ *" or "* /". It also performs a
56
+ first pass to remove one surrounding comment to avoid compatibility
57
+ issues for users relying on the existing removal.
58
+
59
+ This also clarifies in the documentation of annotate that it should not
60
+ be provided user input.
61
+
62
+ [CVE-2023-22794]
63
+
64
+ * Added integer width check to PostgreSQL::Quoting
65
+
66
+ Given a value outside the range for a 64bit signed integer type
67
+ PostgreSQL will treat the column type as numeric. Comparing
68
+ integer values against numeric values can result in a slow
69
+ sequential scan.
70
+
71
+ This behavior is configurable via
72
+ ActiveRecord::Base.raise_int_wider_than_64bit which defaults to true.
73
+
74
+ [CVE-2022-44566]
75
+
76
+ ## Rails 6.1.7 (September 09, 2022) ##
77
+
78
+ * Symbol is allowed by default for YAML columns
79
+
80
+ *Étienne Barrié*
81
+
82
+ * Fix `ActiveRecord::Store` to serialize as a regular Hash
83
+
84
+ Previously it would serialize as an `ActiveSupport::HashWithIndifferentAccess`
85
+ which is wasteful and cause problem with YAML safe_load.
86
+
87
+ *Jean Boussier*
88
+
89
+ * Fix PG.connect keyword arguments deprecation warning on ruby 2.7
90
+
91
+ Fixes #44307.
92
+
93
+ *Nikita Vasilevsky*
94
+
95
+ ## Rails 6.1.6.1 (July 12, 2022) ##
96
+
97
+ * Change ActiveRecord::Coders::YAMLColumn default to safe_load
98
+
99
+ This adds two new configuration options The configuration options are as
100
+ follows:
101
+
102
+ * `config.active_storage.use_yaml_unsafe_load`
103
+
104
+ When set to true, this configuration option tells Rails to use the old
105
+ "unsafe" YAML loading strategy, maintaining the existing behavior but leaving
106
+ the possible escalation vulnerability in place. Setting this option to true
107
+ is *not* recommended, but can aid in upgrading.
108
+
109
+ * `config.active_record.yaml_column_permitted_classes`
110
+
111
+ The "safe YAML" loading method does not allow all classes to be deserialized
112
+ by default. This option allows you to specify classes deemed "safe" in your
113
+ application. For example, if your application uses Symbol and Time in
114
+ serialized data, you can add Symbol and Time to the allowed list as follows:
115
+
116
+ ```
117
+ config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time]
118
+ ```
119
+
120
+ [CVE-2022-32224]
121
+
122
+
123
+ ## Rails 6.1.6 (May 09, 2022) ##
124
+
125
+ * No changes.
126
+
127
+
128
+ ## Rails 6.1.5.1 (April 26, 2022) ##
129
+
130
+ * No changes.
131
+
132
+
133
+ ## Rails 6.1.5 (March 09, 2022) ##
134
+
135
+ * Fix `ActiveRecord::ConnectionAdapters::SchemaCache#deep_deduplicate` for Ruby 2.6.
136
+
137
+ Ruby 2.6 and 2.7 have slightly different implementations of the `String#-@` method.
138
+ In Ruby 2.6, the receiver of the `String#-@` method is modified under certain circumstances.
139
+ This was later identified as a bug (https://bugs.ruby-lang.org/issues/15926) and only
140
+ fixed in Ruby 2.7.
141
+
142
+ Before the changes in this commit, the
143
+ `ActiveRecord::ConnectionAdapters::SchemaCache#deep_deduplicate` method, which internally
144
+ calls the `String#-@` method, could also modify an input string argument in Ruby 2.6 --
145
+ changing a tainted, unfrozen string into a tainted, frozen string.
146
+
147
+ Fixes #43056
148
+
149
+ *Eric O'Hanlon*
150
+
151
+ * Fix migration compatibility to create SQLite references/belongs_to column as integer when
152
+ migration version is 6.0.
153
+
154
+ `reference`/`belongs_to` in migrations with version 6.0 were creating columns as
155
+ bigint instead of integer for the SQLite Adapter.
156
+
157
+ *Marcelo Lauxen*
158
+
159
+ * Fix dbconsole for 3-tier config.
160
+
161
+ *Eileen M. Uchitelle*
162
+
163
+ * Better handle SQL queries with invalid encoding.
164
+
165
+ ```ruby
166
+ Post.create(name: "broken \xC8 UTF-8")
167
+ ```
168
+
169
+ Would cause all adapters to fail in a non controlled way in the code
170
+ responsible to detect write queries.
171
+
172
+ The query is now properly passed to the database connection, which might or might
173
+ not be able to handle it, but will either succeed or failed in a more correct way.
174
+
175
+ *Jean Boussier*
176
+
177
+ * Ignore persisted in-memory records when merging target lists.
178
+
179
+ *Kevin Sjöberg*
180
+
181
+ * Fix regression bug that caused ignoring additional conditions for preloading
182
+ `has_many` through relations.
183
+
184
+ Fixes #43132
185
+
186
+ *Alexander Pauly*
187
+
188
+ * Fix `ActiveRecord::InternalMetadata` to not be broken by
189
+ `config.active_record.record_timestamps = false`
190
+
191
+ Since the model always create the timestamp columns, it has to set them, otherwise it breaks
192
+ various DB management tasks.
193
+
194
+ Fixes #42983
195
+
196
+ *Jean Boussier*
197
+
198
+ * Fix duplicate active record objects on `inverse_of`.
199
+
200
+ *Justin Carvalho*
201
+
202
+ * Fix duplicate objects stored in has many association after save.
203
+
204
+ Fixes #42549.
205
+
206
+ *Alex Ghiculescu*
207
+
208
+ * Fix performance regression in `CollectionAssocation#build`.
209
+
210
+ *Alex Ghiculescu*
211
+
212
+ * Fix retrieving default value for text column for MariaDB.
213
+
214
+ *fatkodima*
215
+
216
+
217
+ ## Rails 6.1.4.7 (March 08, 2022) ##
218
+
219
+ * No changes.
220
+
221
+
222
+ ## Rails 6.1.4.6 (February 11, 2022) ##
223
+
224
+ * No changes.
225
+
226
+
227
+ ## Rails 6.1.4.5 (February 11, 2022) ##
228
+
229
+ * No changes.
230
+
231
+
232
+ ## Rails 6.1.4.4 (December 15, 2021) ##
233
+
234
+ * No changes.
235
+
236
+
237
+ ## Rails 6.1.4.3 (December 14, 2021) ##
238
+
239
+ * No changes.
240
+
241
+
242
+ ## Rails 6.1.4.2 (December 14, 2021) ##
243
+
244
+ * No changes.
245
+
246
+
1
247
  ## Rails 6.1.4.1 (August 19, 2021) ##
2
248
 
3
249
  * No changes.
@@ -72,10 +318,10 @@
72
318
  ```
73
319
 
74
320
  In the example, `dog.treats` would still raise even though
75
- `strict_loading` was set to false. This is a bug effecting more than
76
- Active Storage which is why I made this PR superceeding #41461. We need
321
+ `strict_loading` was set to false. This is a bug affecting more than
322
+ Active Storage which is why I made this PR superseding #41461. We need
77
323
  to fix this for all applications since the behavior is a little
78
- surprising. I took the test from ##41461 and the code suggestion from #41453
324
+ surprising. I took the test from #41461 and the code suggestion from #41453
79
325
  with some additions.
80
326
 
81
327
  *Eileen M. Uchitelle*, *Radamés Roriz*
@@ -577,7 +823,7 @@
577
823
 
578
824
  attribute :duration, :interval
579
825
 
580
- To keep old behavior until 6.2 is released:
826
+ To keep old behavior until 7.0 is released:
581
827
 
582
828
  attribute :duration, :string
583
829
 
@@ -749,8 +995,8 @@
749
995
  *Ryuta Kamizono*
750
996
 
751
997
  * Merging conditions on the same column no longer maintain both conditions,
752
- and will be consistently replaced by the latter condition in Rails 6.2.
753
- To migrate to Rails 6.2's behavior, use `relation.merge(other, rewhere: true)`.
998
+ and will be consistently replaced by the latter condition in Rails 7.0.
999
+ To migrate to Rails 7.0's behavior, use `relation.merge(other, rewhere: true)`.
754
1000
 
755
1001
  ```ruby
756
1002
  # Rails 6.1 (IN clause is replaced by merger side equality condition)
@@ -759,10 +1005,10 @@
759
1005
  # Rails 6.1 (both conflict conditions exists, deprecated)
760
1006
  Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => []
761
1007
 
762
- # Rails 6.1 with rewhere to migrate to Rails 6.2's behavior
1008
+ # Rails 6.1 with rewhere to migrate to Rails 7.0's behavior
763
1009
  Author.where(id: david.id..mary.id).merge(Author.where(id: bob), rewhere: true) # => [bob]
764
1010
 
765
- # Rails 6.2 (same behavior with IN clause, mergee side condition is consistently replaced)
1011
+ # Rails 7.0 (same behavior with IN clause, mergee side condition is consistently replaced)
766
1012
  Author.where(id: [david.id, mary.id]).merge(Author.where(id: bob)) # => [bob]
767
1013
  Author.where(id: david.id..mary.id).merge(Author.where(id: bob)) # => [bob]
768
1014
  ```
@@ -854,7 +1100,7 @@
854
1100
 
855
1101
  * Deprecate aggregations with group by duplicated fields.
856
1102
 
857
- To migrate to Rails 6.2's behavior, use `uniq!(:group)` to deduplicate group fields.
1103
+ To migrate to Rails 7.0's behavior, use `uniq!(:group)` to deduplicate group fields.
858
1104
 
859
1105
  ```ruby
860
1106
  accounts = Account.group(:firm_id)
@@ -878,7 +1124,7 @@
878
1124
 
879
1125
  * Deprecate duplicated query annotations.
880
1126
 
881
- To migrate to Rails 6.2's behavior, use `uniq!(:annotate)` to deduplicate query annotations.
1127
+ To migrate to Rails 7.0's behavior, use `uniq!(:annotate)` to deduplicate query annotations.
882
1128
 
883
1129
  ```ruby
884
1130
  accounts = Account.where(id: [1, 2]).annotate("david and mary")
@@ -1299,13 +1545,13 @@
1299
1545
 
1300
1546
  * Deprecate `#remove_connection` in favor of `#remove_connection_pool` when called on the handler.
1301
1547
 
1302
- `#remove_connection` is deprecated in order to support returning a `DatabaseConfig` object instead of a `Hash`. Use `#remove_connection_pool`, `#remove_connection` will be removed in 6.2.
1548
+ `#remove_connection` is deprecated in order to support returning a `DatabaseConfig` object instead of a `Hash`. Use `#remove_connection_pool`, `#remove_connection` will be removed in Rails 7.0.
1303
1549
 
1304
1550
  *Eileen M. Uchitelle*, *John Crepezzi*
1305
1551
 
1306
1552
  * Deprecate `#default_hash` and it's alias `#[]` on database configurations.
1307
1553
 
1308
- Applications should use `configs_for`. `#default_hash` and `#[]` will be removed in 6.2.
1554
+ Applications should use `configs_for`. `#default_hash` and `#[]` will be removed in Rails 7.0.
1309
1555
 
1310
1556
  *Eileen M. Uchitelle*, *John Crepezzi*
1311
1557
 
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2004-2020 David Heinemeier Hansson
1
+ Copyright (c) 2004-2022 David Heinemeier Hansson
2
2
 
3
3
  Arel originally copyright (c) 2007-2016 Nick Kallen, Bryan Helmkamp, Emilio Tagua, Aaron Patterson
4
4
 
@@ -75,6 +75,7 @@ module ActiveRecord
75
75
  def reset
76
76
  super
77
77
  @target = []
78
+ @replaced_or_added_targets = Set.new
78
79
  @association_ids = nil
79
80
  end
80
81
 
@@ -279,10 +280,7 @@ module ActiveRecord
279
280
  end
280
281
 
281
282
  def add_to_target(record, skip_callbacks: false, replace: false, &block)
282
- if replace || association_scope.distinct_value
283
- index = @target.index(record)
284
- end
285
- replace_on_target(record, index, skip_callbacks, &block)
283
+ replace_on_target(record, skip_callbacks, replace: replace || association_scope.distinct_value, &block)
286
284
  end
287
285
 
288
286
  def target=(record)
@@ -292,7 +290,7 @@ module ActiveRecord
292
290
  when Array
293
291
  super
294
292
  else
295
- add_to_target(record, skip_callbacks: true, replace: true)
293
+ replace_on_target(record, true, replace: true, inversing: true)
296
294
  end
297
295
  end
298
296
 
@@ -342,7 +340,7 @@ module ActiveRecord
342
340
  end
343
341
  end
344
342
 
345
- persisted + memory
343
+ persisted + memory.reject(&:persisted?)
346
344
  end
347
345
 
348
346
  def _create_record(attributes, raise = false, &block)
@@ -425,7 +423,7 @@ module ActiveRecord
425
423
  common_records = intersection(new_target, original_target)
426
424
  common_records.each do |record|
427
425
  skip_callbacks = true
428
- replace_on_target(record, @target.index(record), skip_callbacks)
426
+ replace_on_target(record, skip_callbacks, replace: true)
429
427
  end
430
428
  end
431
429
 
@@ -448,7 +446,11 @@ module ActiveRecord
448
446
  records
449
447
  end
450
448
 
451
- def replace_on_target(record, index, skip_callbacks)
449
+ def replace_on_target(record, skip_callbacks, replace:, inversing: false)
450
+ if replace && (!record.new_record? || @replaced_or_added_targets.include?(record))
451
+ index = @target.index(record)
452
+ end
453
+
452
454
  catch(:abort) do
453
455
  callback(:before_add, record)
454
456
  end || return unless skip_callbacks
@@ -459,6 +461,12 @@ module ActiveRecord
459
461
 
460
462
  yield(record) if block_given?
461
463
 
464
+ if !index && @replaced_or_added_targets.include?(record)
465
+ index = @target.index(record)
466
+ end
467
+
468
+ @replaced_or_added_targets << record if inversing || index || record.new_record?
469
+
462
470
  if index
463
471
  target[index] = record
464
472
  elsif @_was_loaded || !loaded?
@@ -129,9 +129,7 @@ module ActiveRecord
129
129
  end
130
130
 
131
131
  def reflection_scope
132
- @reflection_scope ||= begin
133
- reflection.join_scopes(klass.arel_table, klass.predicate_builder, klass).inject(&:merge!) || klass.unscoped
134
- end
132
+ @reflection_scope ||= reflection.join_scopes(klass.arel_table, klass.predicate_builder, klass).inject(klass.unscoped, &:merge!)
135
133
  end
136
134
 
137
135
  def build_scope
@@ -47,11 +47,23 @@ module ActiveRecord
47
47
 
48
48
  if YAML.respond_to?(:unsafe_load)
49
49
  def yaml_load(payload)
50
- YAML.unsafe_load(payload)
50
+ if ActiveRecord::Base.use_yaml_unsafe_load
51
+ YAML.unsafe_load(payload)
52
+ elsif YAML.method(:safe_load).parameters.include?([:key, :permitted_classes])
53
+ YAML.safe_load(payload, permitted_classes: ActiveRecord::Base.yaml_column_permitted_classes, aliases: true)
54
+ else
55
+ YAML.safe_load(payload, ActiveRecord::Base.yaml_column_permitted_classes, [], true)
56
+ end
51
57
  end
52
58
  else
53
59
  def yaml_load(payload)
54
- YAML.load(payload)
60
+ if ActiveRecord::Base.use_yaml_unsafe_load
61
+ YAML.load(payload)
62
+ elsif YAML.method(:safe_load).parameters.include?([:key, :permitted_classes])
63
+ YAML.safe_load(payload, permitted_classes: ActiveRecord::Base.yaml_column_permitted_classes, aliases: true)
64
+ else
65
+ YAML.safe_load(payload, ActiveRecord::Base.yaml_column_permitted_classes, [], true)
66
+ end
55
67
  end
56
68
  end
57
69
  end
@@ -1177,7 +1177,7 @@ module ActiveRecord
1177
1177
  return owner_to_pool_manager[owner] if owner_to_pool_manager.key?(owner)
1178
1178
 
1179
1179
  if owner == "primary"
1180
- ActiveSupport::Deprecation.warn("Using `\"primary\"` as a `connection_specification_name` is deprecated and will be removed in Rails 6.2.0. Please use `ActiveRecord::Base`.")
1180
+ ActiveSupport::Deprecation.warn("Using `\"primary\"` as a `connection_specification_name` is deprecated and will be removed in Rails 7.0.0. Please use `ActiveRecord::Base`.")
1181
1181
  owner_to_pool_manager[Base.name]
1182
1182
  end
1183
1183
  end
@@ -12,7 +12,7 @@ module ActiveRecord
12
12
  if value.is_a?(Base)
13
13
  ActiveSupport::Deprecation.warn(<<~MSG)
14
14
  Passing an Active Record object to `quote` directly is deprecated
15
- and will be no longer quoted as id value in Rails 6.2.
15
+ and will be no longer quoted as id value in Rails 7.0.
16
16
  MSG
17
17
  value = value.id_for_database
18
18
  end
@@ -27,14 +27,14 @@ module ActiveRecord
27
27
  if value.is_a?(Base)
28
28
  ActiveSupport::Deprecation.warn(<<~MSG)
29
29
  Passing an Active Record object to `type_cast` directly is deprecated
30
- and will be no longer type casted as id value in Rails 6.2.
30
+ and will be no longer type casted as id value in Rails 7.0.
31
31
  MSG
32
32
  value = value.id_for_database
33
33
  end
34
34
 
35
35
  if column
36
36
  ActiveSupport::Deprecation.warn(<<~MSG)
37
- Passing a column to `type_cast` is deprecated and will be removed in Rails 6.2.
37
+ Passing a column to `type_cast` is deprecated and will be removed in Rails 7.0.
38
38
  MSG
39
39
  type = lookup_cast_type_from_column(column)
40
40
  value = type.serialize(value)
@@ -138,7 +138,16 @@ module ActiveRecord
138
138
  end
139
139
 
140
140
  def sanitize_as_sql_comment(value) # :nodoc:
141
- value.to_s.gsub(%r{ (/ (?: | \g<1>) \*) \+? \s* | \s* (\* (?: | \g<2>) /) }x, "")
141
+ # Sanitize a string to appear within a SQL comment
142
+ # For compatibility, this also surrounding "/*+", "/*", and "*/"
143
+ # charcacters, possibly with single surrounding space.
144
+ # Then follows that by replacing any internal "*/" or "/ *" with
145
+ # "* /" or "/ *"
146
+ comment = value.to_s.dup
147
+ comment.gsub!(%r{\A\s*/\*\+?\s?|\s?\*/\s*\Z}, "")
148
+ comment.gsub!("*/", "* /")
149
+ comment.gsub!("/*", "/ *")
150
+ comment
142
151
  end
143
152
 
144
153
  def column_name_matcher # :nodoc:
@@ -198,6 +198,10 @@ module ActiveRecord
198
198
 
199
199
  def index_options(table_name)
200
200
  index_options = as_options(index)
201
+
202
+ # legacy reference index names are used on versions 6.0 and earlier
203
+ return index_options if options[:_uses_legacy_reference_index_name]
204
+
201
205
  index_options[:name] ||= polymorphic_index_name(table_name) if polymorphic
202
206
  index_options
203
207
  end
@@ -26,6 +26,8 @@ module ActiveRecord
26
26
 
27
27
  def write_query?(sql) # :nodoc:
28
28
  !READ_QUERY.match?(sql)
29
+ rescue ArgumentError # Invalid encoding
30
+ !READ_QUERY.match?(sql.b)
29
31
  end
30
32
 
31
33
  def explain(arel, binds = [])
@@ -167,6 +167,9 @@ module ActiveRecord
167
167
  elsif type_metadata.extra == "DEFAULT_GENERATED"
168
168
  default = +"(#{default})" unless default.start_with?("(")
169
169
  default, default_function = nil, default
170
+ elsif type_metadata.type == :text && default
171
+ # strip and unescape quotes
172
+ default = default[1...-1].gsub("\\'", "'")
170
173
  end
171
174
 
172
175
  MySQL::Column.new(
@@ -203,7 +206,7 @@ module ActiveRecord
203
206
  def data_source_sql(name = nil, type: nil)
204
207
  scope = quoted_scope(name, type: type)
205
208
 
206
- sql = +"SELECT table_name FROM (SELECT * FROM information_schema.tables "
209
+ sql = +"SELECT table_name FROM (SELECT table_name, table_type FROM information_schema.tables "
207
210
  sql << " WHERE table_schema = #{scope[:schema]}) _subquery"
208
211
  if scope[:type] || scope[:name]
209
212
  conditions = []
@@ -28,6 +28,8 @@ module ActiveRecord
28
28
 
29
29
  def write_query?(sql) # :nodoc:
30
30
  !READ_QUERY.match?(sql)
31
+ rescue ArgumentError # Invalid encoding
32
+ !READ_QUERY.match?(sql.b)
31
33
  end
32
34
 
33
35
  # Executes an SQL statement, returning a PG::Result object on success
@@ -4,6 +4,12 @@ module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module PostgreSQL
6
6
  module Quoting
7
+ class IntegerOutOf64BitRange < StandardError
8
+ def initialize(msg)
9
+ super(msg)
10
+ end
11
+ end
12
+
7
13
  # Escapes binary strings for bytea input to the database.
8
14
  def escape_bytea(value)
9
15
  @connection.escape_bytea(value) if value
@@ -120,7 +126,27 @@ module ActiveRecord
120
126
  super(query_value("SELECT #{quote(sql_type)}::regtype::oid", "SCHEMA").to_i)
121
127
  end
122
128
 
129
+ def check_int_in_range(value)
130
+ if value.to_int > 9223372036854775807 || value.to_int < -9223372036854775808
131
+ exception = <<~ERROR
132
+ Provided value outside of the range of a signed 64bit integer.
133
+
134
+ PostgreSQL will treat the column type in question as a numeric.
135
+ This may result in a slow sequential scan due to a comparison
136
+ being performed between an integer or bigint value and a numeric value.
137
+
138
+ To allow for this potentially unwanted behavior, set
139
+ ActiveRecord::Base.raise_int_wider_than_64bit to false.
140
+ ERROR
141
+ raise IntegerOutOf64BitRange.new exception
142
+ end
143
+ end
144
+
123
145
  def _quote(value)
146
+ if ActiveRecord::Base.raise_int_wider_than_64bit && value.is_a?(Integer)
147
+ check_int_in_range(value)
148
+ end
149
+
124
150
  case value
125
151
  when OID::Xml::Data
126
152
  "xml '#{quote_string(value.to_s)}'"
@@ -75,7 +75,7 @@ module ActiveRecord
75
75
 
76
76
  class << self
77
77
  def new_client(conn_params)
78
- PG.connect(conn_params)
78
+ PG.connect(**conn_params)
79
79
  rescue ::PG::Error => error
80
80
  if conn_params && conn_params[:dbname] && error.message.include?(conn_params[:dbname])
81
81
  raise ActiveRecord::NoDatabaseError
@@ -247,7 +247,7 @@ module ActiveRecord
247
247
  def initialize(connection, logger, connection_parameters, config)
248
248
  super(connection, logger, config)
249
249
 
250
- @connection_parameters = connection_parameters
250
+ @connection_parameters = connection_parameters || {}
251
251
 
252
252
  # @local_tz is initialized as nil to avoid warnings when connect tries to use it
253
253
  @local_tz = nil
@@ -198,16 +198,40 @@ module ActiveRecord
198
198
  @indexes = deep_deduplicate(@indexes)
199
199
  end
200
200
 
201
- def deep_deduplicate(value)
202
- case value
203
- when Hash
204
- value.transform_keys { |k| deep_deduplicate(k) }.transform_values { |v| deep_deduplicate(v) }
205
- when Array
206
- value.map { |i| deep_deduplicate(i) }
207
- when String, Deduplicable
208
- -value
209
- else
210
- value
201
+ if RUBY_VERSION < "2.7"
202
+ def deep_deduplicate(value)
203
+ case value
204
+ when Hash
205
+ value.transform_keys { |k| deep_deduplicate(k) }.transform_values { |v| deep_deduplicate(v) }
206
+ when Array
207
+ value.map { |i| deep_deduplicate(i) }
208
+ when String
209
+ if value.tainted?
210
+ # Ruby 2.6 and 2.7 have slightly different implementations of the String#-@ method.
211
+ # In Ruby 2.6, the receiver of the String#-@ method is modified under certain
212
+ # circumstances, and this was later identified as a bug
213
+ # (https://bugs.ruby-lang.org/issues/15926) and only fixed in Ruby 2.7.
214
+ value = value.dup
215
+ end
216
+ -value
217
+ when Deduplicable
218
+ -value
219
+ else
220
+ value
221
+ end
222
+ end
223
+ else
224
+ def deep_deduplicate(value)
225
+ case value
226
+ when Hash
227
+ value.transform_keys { |k| deep_deduplicate(k) }.transform_values { |v| deep_deduplicate(v) }
228
+ when Array
229
+ value.map { |i| deep_deduplicate(i) }
230
+ when String, Deduplicable
231
+ -value
232
+ else
233
+ value
234
+ end
211
235
  end
212
236
  end
213
237
 
@@ -11,6 +11,8 @@ module ActiveRecord
11
11
 
12
12
  def write_query?(sql) # :nodoc:
13
13
  !READ_QUERY.match?(sql)
14
+ rescue ArgumentError # Invalid encoding
15
+ !READ_QUERY.match?(sql.b)
14
16
  end
15
17
 
16
18
  def explain(arel, binds = [])
@@ -135,7 +135,7 @@ module ActiveRecord
135
135
  # Dog.first # finds first Dog record stored on the shard one replica
136
136
  # end
137
137
  #
138
- # The database kwarg is deprecated and will be removed in 6.2.0 without replacement.
138
+ # The database kwarg is deprecated and will be removed in Rails 7.0.0 without replacement.
139
139
  def connected_to(database: nil, role: nil, shard: nil, prevent_writes: false, &blk)
140
140
  if legacy_connection_handling
141
141
  if self != Base
@@ -154,7 +154,7 @@ module ActiveRecord
154
154
  if database && (role || shard)
155
155
  raise ArgumentError, "`connected_to` cannot accept a `database` argument with any other arguments."
156
156
  elsif database
157
- ActiveSupport::Deprecation.warn("The database key in `connected_to` is deprecated. It will be removed in Rails 6.2.0 without replacement.")
157
+ ActiveSupport::Deprecation.warn("The database key in `connected_to` is deprecated. It will be removed in Rails 7.0.0 without replacement.")
158
158
 
159
159
  if database.is_a?(Hash)
160
160
  role, database = database.first
@@ -155,6 +155,21 @@ module ActiveRecord
155
155
 
156
156
  mattr_accessor :legacy_connection_handling, instance_writer: false, default: true
157
157
 
158
+ # Application configurable boolean that instructs the YAML Coder to use
159
+ # an unsafe load if set to true.
160
+ mattr_accessor :use_yaml_unsafe_load, instance_writer: false, default: false
161
+
162
+ # Application configurable array that provides additional permitted classes
163
+ # to Psych safe_load in the YAML Coder
164
+ mattr_accessor :yaml_column_permitted_classes, instance_writer: false, default: [Symbol]
165
+
166
+ ##
167
+ # :singleton-method:
168
+ # Application configurable boolean that denotes whether or not to raise
169
+ # an exception when the PostgreSQLAdapter is provided with an integer that is
170
+ # wider than signed 64bit representation
171
+ mattr_accessor :raise_int_wider_than_64bit, instance_writer: false, default: true
172
+
158
173
  self.filter_attributes = []
159
174
 
160
175
  def self.connection_handler
@@ -278,11 +293,11 @@ module ActiveRecord
278
293
  end
279
294
 
280
295
  def self.allow_unsafe_raw_sql # :nodoc:
281
- ActiveSupport::Deprecation.warn("ActiveRecord::Base.allow_unsafe_raw_sql is deprecated and will be removed in Rails 6.2")
296
+ ActiveSupport::Deprecation.warn("ActiveRecord::Base.allow_unsafe_raw_sql is deprecated and will be removed in Rails 7.0")
282
297
  end
283
298
 
284
299
  def self.allow_unsafe_raw_sql=(value) # :nodoc:
285
- ActiveSupport::Deprecation.warn("ActiveRecord::Base.allow_unsafe_raw_sql= is deprecated and will be removed in Rails 6.2")
300
+ ActiveSupport::Deprecation.warn("ActiveRecord::Base.allow_unsafe_raw_sql= is deprecated and will be removed in Rails 7.0")
286
301
  end
287
302
 
288
303
  self.default_connection_handler = ConnectionAdapters::ConnectionHandler.new
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "uri"
3
4
  require "active_support/core_ext/enumerable"
4
5
 
5
6
  module ActiveRecord
@@ -32,7 +32,7 @@ module ActiveRecord
32
32
  end
33
33
 
34
34
  def config
35
- ActiveSupport::Deprecation.warn("DatabaseConfig#config will be removed in 6.2.0 in favor of DatabaseConfigurations#configuration_hash which returns a hash with symbol keys")
35
+ ActiveSupport::Deprecation.warn("DatabaseConfig#config will be removed in 7.0.0 in favor of DatabaseConfig#configuration_hash which returns a hash with symbol keys")
36
36
  configuration_hash.stringify_keys
37
37
  end
38
38
 
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "uri"
3
4
  require "active_record/database_configurations/database_config"
4
5
  require "active_record/database_configurations/hash_config"
5
6
  require "active_record/database_configurations/url_config"
@@ -40,7 +41,7 @@ module ActiveRecord
40
41
  def configs_for(env_name: nil, spec_name: nil, name: nil, include_replicas: false)
41
42
  if spec_name
42
43
  name = spec_name
43
- ActiveSupport::Deprecation.warn("The kwarg `spec_name` is deprecated in favor of `name`. `spec_name` will be removed in Rails 6.2")
44
+ ActiveSupport::Deprecation.warn("The kwarg `spec_name` is deprecated in favor of `name`. `spec_name` will be removed in Rails 7.0")
44
45
  end
45
46
 
46
47
  env_name ||= default_env if name
@@ -9,8 +9,8 @@ module ActiveRecord
9
9
  module VERSION
10
10
  MAJOR = 6
11
11
  MINOR = 1
12
- TINY = 4
13
- PRE = "1"
12
+ TINY = 7
13
+ PRE = "10"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -10,6 +10,8 @@ module ActiveRecord
10
10
  # This is enabled by default. To disable this functionality set
11
11
  # `use_metadata_table` to false in your database configuration.
12
12
  class InternalMetadata < ActiveRecord::Base # :nodoc:
13
+ self.record_timestamps = true
14
+
13
15
  class << self
14
16
  def enabled?
15
17
  ActiveRecord::Base.connection.use_metadata_table?
@@ -10,7 +10,7 @@ module ActiveRecord
10
10
  else
11
11
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
12
12
  YAML loading from legacy format older than Rails 5.0 is deprecated
13
- and will be removed in Rails 6.2.
13
+ and will be removed in Rails 7.0.
14
14
  MSG
15
15
  if coder["attributes"].is_a?(ActiveModel::AttributeSet)
16
16
  Rails420.convert(klass, coder)
@@ -24,9 +24,8 @@ module ActiveRecord
24
24
 
25
25
  module TableDefinition
26
26
  def references(*args, **options)
27
- args.each do |ref_name|
28
- ReferenceDefinition.new(ref_name, **options).add_to(self)
29
- end
27
+ options[:_uses_legacy_reference_index_name] = true
28
+ super
30
29
  end
31
30
  alias :belongs_to :references
32
31
  end
@@ -56,8 +55,12 @@ module ActiveRecord
56
55
  end
57
56
 
58
57
  def add_reference(table_name, ref_name, **options)
59
- ReferenceDefinition.new(ref_name, **options)
60
- .add_to(connection.update_table_definition(table_name, self))
58
+ if connection.adapter_name == "SQLite"
59
+ options[:type] = :integer
60
+ end
61
+
62
+ options[:_uses_legacy_reference_index_name] = true
63
+ super
61
64
  end
62
65
  alias :add_belongs_to :add_reference
63
66
 
@@ -126,7 +129,7 @@ module ActiveRecord
126
129
  class << t
127
130
  prepend TableDefinition
128
131
  end
129
- t
132
+ super
130
133
  end
131
134
 
132
135
  def command_recorder
@@ -630,7 +630,7 @@ module ActiveRecord
630
630
  if column.sql_type.start_with?("interval")
631
631
  precision_arguments = column.precision.presence && ", precision: #{column.precision}"
632
632
  ActiveSupport::Deprecation.warn(<<~WARNING)
633
- The behavior of the `:interval` type will be changing in Rails 6.2
633
+ The behavior of the `:interval` type will be changing in Rails 7.0
634
634
  to return an `ActiveSupport::Duration` object. If you'd like to keep
635
635
  the old behavior, you can add this line to #{self.name} model:
636
636
 
@@ -464,7 +464,7 @@ db_namespace = namespace :db do
464
464
 
465
465
  task load_if_ruby: ["db:create", :environment] do
466
466
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
467
- Using `bin/rails db:schema:load_if_ruby` is deprecated and will be removed in Rails 6.2.
467
+ Using `bin/rails db:schema:load_if_ruby` is deprecated and will be removed in Rails 7.0.
468
468
  Configure the format using `config.active_record.schema_format = :ruby` to use `schema.rb` and run `bin/rails db:schema:load` instead.
469
469
  MSG
470
470
  db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :ruby
@@ -527,7 +527,7 @@ db_namespace = namespace :db do
527
527
  desc "Dumps the database structure to db/structure.sql. Specify another file with SCHEMA=db/my_structure.sql"
528
528
  task dump: :load_config do
529
529
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
530
- Using `bin/rails db:structure:dump` is deprecated and will be removed in Rails 6.2.
530
+ Using `bin/rails db:structure:dump` is deprecated and will be removed in Rails 7.0.
531
531
  Configure the format using `config.active_record.schema_format = :sql` to use `structure.sql` and run `bin/rails db:schema:dump` instead.
532
532
  MSG
533
533
 
@@ -538,7 +538,7 @@ db_namespace = namespace :db do
538
538
  desc "Recreates the databases from the structure.sql file"
539
539
  task load: [:load_config, :check_protected_environments] do
540
540
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
541
- Using `bin/rails db:structure:load` is deprecated and will be removed in Rails 6.2.
541
+ Using `bin/rails db:structure:load` is deprecated and will be removed in Rails 7.0.
542
542
  Configure the format using `config.active_record.schema_format = :sql` to use `structure.sql` and run `bin/rails db:schema:load` instead.
543
543
  MSG
544
544
  db_namespace["schema:load"].invoke
@@ -546,7 +546,7 @@ db_namespace = namespace :db do
546
546
 
547
547
  task load_if_sql: ["db:create", :environment] do
548
548
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
549
- Using `bin/rails db:structure:load_if_sql` is deprecated and will be removed in Rails 6.2.
549
+ Using `bin/rails db:structure:load_if_sql` is deprecated and will be removed in Rails 7.0.
550
550
  Configure the format using `config.active_record.schema_format = :sql` to use `structure.sql` and run `bin/rails db:schema:load` instead.
551
551
  MSG
552
552
  db_namespace["schema:load"].invoke if ActiveRecord::Base.schema_format == :sql
@@ -557,7 +557,7 @@ db_namespace = namespace :db do
557
557
  desc "Dumps the #{name} database structure to db/structure.sql. Specify another file with SCHEMA=db/my_structure.sql"
558
558
  task name => :load_config do
559
559
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
560
- Using `bin/rails db:structure:dump:#{name}` is deprecated and will be removed in Rails 6.2.
560
+ Using `bin/rails db:structure:dump:#{name}` is deprecated and will be removed in Rails 7.0.
561
561
  Configure the format using `config.active_record.schema_format = :sql` to use `structure.sql` and run `bin/rails db:schema:dump:#{name}` instead.
562
562
  MSG
563
563
  db_namespace["schema:dump:#{name}"].invoke
@@ -571,7 +571,7 @@ db_namespace = namespace :db do
571
571
  desc "Recreates the #{name} database from the structure.sql file"
572
572
  task name => :load_config do
573
573
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
574
- Using `bin/rails db:structure:load:#{name}` is deprecated and will be removed in Rails 6.2.
574
+ Using `bin/rails db:structure:load:#{name}` is deprecated and will be removed in Rails 7.0.
575
575
  Configure the format using `config.active_record.schema_format = :sql` to use `structure.sql` and run `bin/rails db:schema:load:#{name}` instead.
576
576
  MSG
577
577
  db_namespace["schema:load:#{name}"].invoke
@@ -603,7 +603,7 @@ db_namespace = namespace :db do
603
603
  # desc "Recreate the test database from an existent structure.sql file"
604
604
  task load_structure: %w(db:test:purge) do
605
605
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
606
- Using `bin/rails db:test:load_structure` is deprecated and will be removed in Rails 6.2.
606
+ Using `bin/rails db:test:load_structure` is deprecated and will be removed in Rails 7.0.
607
607
  Configure the format using `config.active_record.schema_format = :sql` to use `structure.sql` and run `bin/rails db:test:load_schema` instead.
608
608
  MSG
609
609
  db_namespace["test:load_schema"].invoke
@@ -650,7 +650,7 @@ db_namespace = namespace :db do
650
650
  namespace :load_structure do
651
651
  task name => "db:test:purge:#{name}" do
652
652
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
653
- Using `bin/rails db:test:load_structure:#{name}` is deprecated and will be removed in Rails 6.2.
653
+ Using `bin/rails db:test:load_structure:#{name}` is deprecated and will be removed in Rails 7.0.
654
654
  Configure the format using `config.active_record.schema_format = :sql` to use `structure.sql` and run `bin/rails db:test:load_structure:#{name}` instead.
655
655
  MSG
656
656
  db_namespace["test:load_schema:#{name}"].invoke
@@ -321,8 +321,8 @@ module ActiveRecord
321
321
 
322
322
  unless group_fields == group_values
323
323
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
324
- `#{operation}` with group by duplicated fields does no longer affect to result in Rails 6.2.
325
- To migrate to Rails 6.2's behavior, use `uniq!(:group)` to deduplicate group fields
324
+ `#{operation}` with group by duplicated fields does no longer affect to result in Rails 7.0.
325
+ To migrate to Rails 7.0's behavior, use `uniq!(:group)` to deduplicate group fields
326
326
  (`#{klass.name&.tableize || klass.table_name}.uniq!(:group).#{operation}(#{column_name.inspect})`).
327
327
  MSG
328
328
  group_fields = group_values
@@ -369,7 +369,7 @@ module ActiveRecord
369
369
  blank_value = order_values.first
370
370
  ActiveSupport::Deprecation.warn(<<~MSG.squish)
371
371
  `.reorder(#{blank_value.inspect})` with `.first` / `.first!` no longer
372
- takes non-deterministic result in Rails 6.2.
372
+ takes non-deterministic result in Rails 7.0.
373
373
  To continue taking non-deterministic result, use `.take` / `.take!` instead.
374
374
  MSG
375
375
  end
@@ -1035,6 +1035,8 @@ module ActiveRecord
1035
1035
  # # SELECT "users"."name" FROM "users" /* selecting */ /* user */ /* names */
1036
1036
  #
1037
1037
  # The SQL block comment delimiters, "/*" and "*/", will be added automatically.
1038
+ #
1039
+ # Some escaping is performed, however untrusted user input should not be used.
1038
1040
  def annotate(*args)
1039
1041
  check_if_method_has_arguments!(:annotate, args)
1040
1042
  spawn.annotate!(*args)
@@ -1157,8 +1159,8 @@ module ActiveRecord
1157
1159
  annotates = annotates.uniq if annotates.size > 1
1158
1160
  unless annotates == annotate_values
1159
1161
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
1160
- Duplicated query annotations are no longer shown in queries in Rails 6.2.
1161
- To migrate to Rails 6.2's behavior, use `uniq!(:annotate)` to deduplicate query annotations
1162
+ Duplicated query annotations are no longer shown in queries in Rails 7.0.
1163
+ To migrate to Rails 7.0's behavior, use `uniq!(:annotate)` to deduplicate query annotations
1162
1164
  (`#{klass.name&.tableize || klass.table_name}.uniq!(:annotate)`).
1163
1165
  MSG
1164
1166
  annotates = annotate_values
@@ -168,8 +168,8 @@ module ActiveRecord
168
168
  else
169
169
  ActiveSupport::Deprecation.warn(<<-MSG.squish)
170
170
  Merging (#{node.to_sql}) and (#{ref.to_sql}) no longer maintain
171
- both conditions, and will be replaced by the latter in Rails 6.2.
172
- To migrate to Rails 6.2's behavior, use `relation.merge(other, rewhere: true)`.
171
+ both conditions, and will be replaced by the latter in Rails 7.0.
172
+ To migrate to Rails 7.0's behavior, use `relation.merge(other, rewhere: true)`.
173
173
  MSG
174
174
  false
175
175
  end
@@ -268,7 +268,7 @@ module ActiveRecord
268
268
  end
269
269
 
270
270
  def dump(obj)
271
- @coder.dump self.class.as_indifferent_hash(obj)
271
+ @coder.dump as_regular_hash(obj)
272
272
  end
273
273
 
274
274
  def load(yaml)
@@ -285,6 +285,11 @@ module ActiveRecord
285
285
  ActiveSupport::HashWithIndifferentAccess.new
286
286
  end
287
287
  end
288
+
289
+ private
290
+ def as_regular_hash(obj)
291
+ obj.respond_to?(:to_hash) ? obj.to_hash : {}
292
+ end
288
293
  end
289
294
  end
290
295
  end
@@ -340,7 +340,7 @@ module ActiveRecord
340
340
  db_config = resolve_configuration(configuration)
341
341
 
342
342
  if environment || name
343
- ActiveSupport::Deprecation.warn("`environment` and `name` will be removed as parameters in 6.2.0, you may now pass an ActiveRecord::DatabaseConfigurations::DatabaseConfig as `configuration` instead.")
343
+ ActiveSupport::Deprecation.warn("`environment` and `name` will be removed as parameters in 7.0.0, you may now pass an ActiveRecord::DatabaseConfigurations::DatabaseConfig as `configuration` instead.")
344
344
  end
345
345
 
346
346
  name ||= db_config.name
@@ -134,7 +134,7 @@ module ActiveRecord
134
134
  @connection_subscriber = ActiveSupport::Notifications.subscribe("!connection.active_record") do |_, _, _, _, payload|
135
135
  spec_name = payload[:spec_name] if payload.key?(:spec_name)
136
136
  shard = payload[:shard] if payload.key?(:shard)
137
- setup_shared_connection_pool
137
+ setup_shared_connection_pool if ActiveRecord::Base.legacy_connection_handling
138
138
 
139
139
  if spec_name
140
140
  begin
@@ -143,10 +143,14 @@ module ActiveRecord
143
143
  connection = nil
144
144
  end
145
145
 
146
- if connection && !@fixture_connections.include?(connection)
147
- connection.begin_transaction joinable: false, _lazy: false
148
- connection.pool.lock_thread = true if lock_threads
149
- @fixture_connections << connection
146
+ if connection
147
+ setup_shared_connection_pool unless ActiveRecord::Base.legacy_connection_handling
148
+
149
+ if !@fixture_connections.include?(connection)
150
+ connection.begin_transaction joinable: false, _lazy: false
151
+ connection.pool.lock_thread = true if lock_threads
152
+ @fixture_connections << connection
153
+ end
150
154
  end
151
155
  end
152
156
  end
data/lib/active_record.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  #--
4
- # Copyright (c) 2004-2020 David Heinemeier Hansson
4
+ # Copyright (c) 2004-2022 David Heinemeier Hansson
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining
7
7
  # a copy of this software and associated documentation files (the
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: 6.1.4.1
4
+ version: 6.1.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-19 00:00:00.000000000 Z
11
+ date: 2024-10-23 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: 6.1.4.1
19
+ version: 6.1.7.10
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: 6.1.4.1
26
+ version: 6.1.7.10
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: 6.1.4.1
33
+ version: 6.1.7.10
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: 6.1.4.1
40
+ version: 6.1.7.10
41
41
  description: Databases on Rails. Build a persistent domain model by mapping database
42
42
  tables to Ruby classes. Strong conventions for associations, validations, aggregations,
43
43
  migrations, and testing come baked-in.
@@ -390,11 +390,12 @@ licenses:
390
390
  - MIT
391
391
  metadata:
392
392
  bug_tracker_uri: https://github.com/rails/rails/issues
393
- changelog_uri: https://github.com/rails/rails/blob/v6.1.4.1/activerecord/CHANGELOG.md
394
- documentation_uri: https://api.rubyonrails.org/v6.1.4.1/
393
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.7.10/activerecord/CHANGELOG.md
394
+ documentation_uri: https://api.rubyonrails.org/v6.1.7.10/
395
395
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
396
- source_code_uri: https://github.com/rails/rails/tree/v6.1.4.1/activerecord
397
- post_install_message:
396
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.7.10/activerecord
397
+ rubygems_mfa_required: 'true'
398
+ post_install_message:
398
399
  rdoc_options:
399
400
  - "--main"
400
401
  - README.rdoc
@@ -411,8 +412,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
411
412
  - !ruby/object:Gem::Version
412
413
  version: '0'
413
414
  requirements: []
414
- rubygems_version: 3.2.15
415
- signing_key:
415
+ rubygems_version: 3.5.16
416
+ signing_key:
416
417
  specification_version: 4
417
418
  summary: Object-relational mapper framework (part of Rails).
418
419
  test_files: []