activerecord 7.1.0.rc1 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 740af6b88b6b54646450a59ad5dfa1b03ca0848f6a0e35d144c0501450c95813
4
- data.tar.gz: 116d5b18e58370804b0888cd01443af9c0d3d760f9ef8c6f0374572e592c1396
3
+ metadata.gz: 8c1c4576a55f62b03c5c65f85726c7a054dcf2265c0596ab2b836366f70de537
4
+ data.tar.gz: 8e1a2827cfc53bef1deaba5901134b589bac138711e37ac34fcf95254372b875
5
5
  SHA512:
6
- metadata.gz: 4f6fd78b9fcd2d861501a1fb76e1c0575da14b158de781ef466c0568b1b3842efcf8213128a95e71cb8414e1ea5bc617850eb19cb30a05e45f5239633fa5023e
7
- data.tar.gz: ed6ccf8f8470fba640ea0a18ccf2c2e5c62cabcd0a21cd9635acd2a9f1db63b22dd4fbd13d2474a020182f703ed3b0e9a11d34389654ae2fb6b7da23deab25f2
6
+ metadata.gz: 13a36c3bbd80622c3a266fd79883baa35dec93e3624d92718cc0fa56f6f4c23dfab83e6fd702e4a8e35b6e4a6f2e81fcc24f8c9e7a71c8d9e791f71bccb9536e
7
+ data.tar.gz: 0b132373d4dda124cc61707c5cd9e08e5cabb68815ed8650de2250becc5d0856610b3622a0d18434bd5182d84cf31fb6b20117d5b0d8ef28ef7698fdcfcc28b4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## Rails 7.1.0 (October 05, 2023) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 7.1.0.rc2 (October 01, 2023) ##
7
+
8
+ * Remove -shm and -wal SQLite files when `rails db:drop` is run.
9
+
10
+ *Niklas Häusele*
11
+
12
+ * Revert the change to raise an `ArgumentError` when `#accepts_nested_attributes_for` is declared more than once for
13
+ an association in the same class.
14
+
15
+ The reverted behavior broke the case where the `#accepts_nested_attributes_for` was defined in a concern and
16
+ where overridden in the class that included the concern.
17
+
18
+ *Rafael Mendonça França*
19
+
20
+
1
21
  ## Rails 7.1.0.rc1 (September 27, 2023) ##
2
22
 
3
23
  * Better naming for unique constraints support.
@@ -75,7 +75,7 @@ module ActiveRecord
75
75
  # for an Author.
76
76
  # - an Array which specifies multiple association names. This array
77
77
  # is processed recursively. For example, specifying <tt>[:avatar, :books]</tt>
78
- # allows this method to preload an author's avatar as well as all of his
78
+ # allows this method to preload an author's avatar as well as all of their
79
79
  # books.
80
80
  # - a Hash which specifies multiple association names, as well as
81
81
  # association names for the to-be-preloaded association objects. For
@@ -1505,7 +1505,7 @@ module ActiveRecord
1505
1505
  # [+:query_constraints+]
1506
1506
  # Serves as a composite foreign key. Defines the list of columns to be used to query the associated object.
1507
1507
  # This is an optional option. By default Rails will attempt to derive the value automatically.
1508
- # When the value is set the Array size must match associated model's primary key or `query_constraints` size.
1508
+ # When the value is set the Array size must match associated model's primary key or +query_constraints+ size.
1509
1509
  #
1510
1510
  # Option examples:
1511
1511
  # has_many :comments, -> { order("posted_on") }
@@ -1689,7 +1689,7 @@ module ActiveRecord
1689
1689
  # [+:query_constraints+]
1690
1690
  # Serves as a composite foreign key. Defines the list of columns to be used to query the associated object.
1691
1691
  # This is an optional option. By default Rails will attempt to derive the value automatically.
1692
- # When the value is set the Array size must match associated model's primary key or `query_constraints` size.
1692
+ # When the value is set the Array size must match associated model's primary key or +query_constraints+ size.
1693
1693
  #
1694
1694
  # Option examples:
1695
1695
  # has_one :credit_card, dependent: :destroy # destroys the associated credit card
@@ -1866,7 +1866,7 @@ module ActiveRecord
1866
1866
  # [+:query_constraints+]
1867
1867
  # Serves as a composite foreign key. Defines the list of columns to be used to query the associated object.
1868
1868
  # This is an optional option. By default Rails will attempt to derive the value automatically.
1869
- # When the value is set the Array size must match associated model's primary key or `query_constraints` size.
1869
+ # When the value is set the Array size must match associated model's primary key or +query_constraints+ size.
1870
1870
  #
1871
1871
  # Option examples:
1872
1872
  # belongs_to :firm, foreign_key: "client_of"
@@ -82,8 +82,11 @@ module ActiveRecord
82
82
  @base_payload = payload
83
83
  end
84
84
 
85
+ class InstrumentationNotStartedError < ActiveRecordError; end
86
+ class InstrumentationAlreadyStartedError < ActiveRecordError; end
87
+
85
88
  def start
86
- return if @started
89
+ raise InstrumentationAlreadyStartedError.new("Called start on an already started transaction") if @started
87
90
  @started = true
88
91
 
89
92
  @payload = @base_payload.dup
@@ -92,7 +95,7 @@ module ActiveRecord
92
95
  end
93
96
 
94
97
  def finish(outcome)
95
- return unless @started
98
+ raise InstrumentationNotStartedError.new("Called finish on a transaction that hasn't started") unless @started
96
99
  @started = false
97
100
 
98
101
  @payload[:outcome] = outcome
@@ -166,7 +169,7 @@ module ActiveRecord
166
169
  end
167
170
 
168
171
  def incomplete!
169
- @instrumenter.finish(:incomplete)
172
+ @instrumenter.finish(:incomplete) if materialized?
170
173
  end
171
174
 
172
175
  def materialize!
@@ -180,6 +183,7 @@ module ActiveRecord
180
183
 
181
184
  def restore!
182
185
  if materialized?
186
+ incomplete!
183
187
  @materialized = false
184
188
  materialize!
185
189
  end
@@ -348,13 +352,13 @@ module ActiveRecord
348
352
  connection.rollback_to_savepoint(savepoint_name) if materialized?
349
353
  end
350
354
  @state.rollback!
351
- @instrumenter.finish(:rollback)
355
+ @instrumenter.finish(:rollback) if materialized?
352
356
  end
353
357
 
354
358
  def commit
355
359
  connection.release_savepoint(savepoint_name) if materialized?
356
360
  @state.commit!
357
- @instrumenter.finish(:commit)
361
+ @instrumenter.finish(:commit) if materialized?
358
362
  end
359
363
 
360
364
  def full_rollback?; false; end
@@ -389,13 +393,13 @@ module ActiveRecord
389
393
  def rollback
390
394
  connection.rollback_db_transaction if materialized?
391
395
  @state.full_rollback!
392
- @instrumenter.finish(:rollback)
396
+ @instrumenter.finish(:rollback) if materialized?
393
397
  end
394
398
 
395
399
  def commit
396
400
  connection.commit_db_transaction if materialized?
397
401
  @state.full_commit!
398
- @instrumenter.finish(:commit)
402
+ @instrumenter.finish(:commit) if materialized?
399
403
  end
400
404
  end
401
405
 
@@ -149,6 +149,7 @@ module ActiveRecord
149
149
  end
150
150
 
151
151
  def lookup_cast_type_from_column(column) # :nodoc:
152
+ verify! if type_map.nil?
152
153
  type_map.lookup(column.oid, column.fmod, column.sql_type)
153
154
  end
154
155
 
@@ -716,9 +716,7 @@ module ActiveRecord
716
716
  end
717
717
 
718
718
  private
719
- def type_map
720
- @type_map ||= Type::HashLookupTypeMap.new
721
- end
719
+ attr_reader :type_map
722
720
 
723
721
  def initialize_type_map(m = type_map)
724
722
  self.class.initialize_type_map(m)
@@ -66,7 +66,7 @@ module ActiveRecord
66
66
  cache(connection).indexes(connection, table_name)
67
67
  end
68
68
 
69
- def database_version(connection)
69
+ def database_version(connection) # :nodoc:
70
70
  cache(connection).database_version(connection)
71
71
  end
72
72
 
@@ -196,7 +196,7 @@ module ActiveRecord
196
196
  @schema_reflection.indexes(@connection, table_name)
197
197
  end
198
198
 
199
- def database_version
199
+ def database_version # :nodoc:
200
200
  @schema_reflection.database_version(@connection)
201
201
  end
202
202
 
@@ -10,7 +10,7 @@ module ActiveRecord
10
10
  MAJOR = 7
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
@@ -553,6 +553,20 @@ module ActiveRecord
553
553
  initialize_find_by_cache
554
554
  end
555
555
 
556
+ def load_schema # :nodoc:
557
+ return if schema_loaded?
558
+ @load_schema_monitor.synchronize do
559
+ return if @columns_hash
560
+
561
+ load_schema!
562
+
563
+ @schema_loaded = true
564
+ rescue
565
+ reload_schema_from_cache # If the schema loading failed half way through, we must reset the state.
566
+ raise
567
+ end
568
+ end
569
+
556
570
  protected
557
571
  def initialize_load_schema_monitor
558
572
  @load_schema_monitor = Monitor.new
@@ -594,20 +608,6 @@ module ActiveRecord
594
608
  defined?(@schema_loaded) && @schema_loaded
595
609
  end
596
610
 
597
- def load_schema
598
- return if schema_loaded?
599
- @load_schema_monitor.synchronize do
600
- return if @columns_hash
601
-
602
- load_schema!
603
-
604
- @schema_loaded = true
605
- rescue
606
- reload_schema_from_cache # If the schema loading failed half way through, we must reset the state.
607
- raise
608
- end
609
- end
610
-
611
611
  def load_schema!
612
612
  unless table_name
613
613
  raise ActiveRecord::TableNotSpecified, "#{self} has no table configured. Set one with #{self}.table_name="
@@ -355,17 +355,12 @@ module ActiveRecord
355
355
  options.update(attr_names.extract_options!)
356
356
  options.assert_valid_keys(:allow_destroy, :reject_if, :limit, :update_only)
357
357
  options[:reject_if] = REJECT_ALL_BLANK_PROC if options[:reject_if] == :all_blank
358
- options[:class] = self
359
358
 
360
359
  attr_names.each do |association_name|
361
360
  if reflection = _reflect_on_association(association_name)
362
361
  reflection.autosave = true
363
362
  define_autosave_validation_callbacks(reflection)
364
363
 
365
- if nested_attributes_options.dig(association_name.to_sym, :class) == self
366
- raise ArgumentError, "Already declared #{association_name} as an accepts_nested_attributes association for this class."
367
- end
368
-
369
364
  nested_attributes_options = self.nested_attributes_options.dup
370
365
  nested_attributes_options[association_name.to_sym] = options
371
366
  self.nested_attributes_options = nested_attributes_options
@@ -1272,7 +1272,7 @@ module ActiveRecord
1272
1272
  def _raise_record_not_destroyed
1273
1273
  @_association_destroy_exception ||= nil
1274
1274
  key = self.class.primary_key
1275
- raise @_association_destroy_exception || RecordNotDestroyed.new("Failed to destroy #{self.class} with #{key}=#{send(key)}", self)
1275
+ raise @_association_destroy_exception || RecordNotDestroyed.new("Failed to destroy #{self.class} with #{key}=#{id}", self)
1276
1276
  ensure
1277
1277
  @_association_destroy_exception = nil
1278
1278
  end
@@ -51,7 +51,7 @@ module ActiveRecord
51
51
  _load_from_sql(_query_by_sql(sql, binds, preparable: preparable), &block)
52
52
  end
53
53
 
54
- # Same as <tt>#find_by_sql</tt> but perform the query asynchronously and returns an ActiveRecord::Promise
54
+ # Same as <tt>#find_by_sql</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
55
55
  def async_find_by_sql(sql, binds = [], preparable: nil, &block)
56
56
  _query_by_sql(sql, binds, preparable: preparable, async: true).then do |result|
57
57
  _load_from_sql(result, &block)
@@ -102,7 +102,7 @@ module ActiveRecord
102
102
  connection.select_value(sanitize_sql(sql), "#{name} Count").to_i
103
103
  end
104
104
 
105
- # Same as <tt>#count_by_sql</tt> but perform the query asynchronously and returns an ActiveRecord::Promise
105
+ # Same as <tt>#count_by_sql</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
106
106
  def async_count_by_sql(sql)
107
107
  connection.select_value(sanitize_sql(sql), "#{name} Count", async: true).then(&:to_i)
108
108
  end
@@ -67,7 +67,7 @@ module ActiveRecord
67
67
  unless ActiveSupport::Logger.logger_outputs_to?(Rails.logger, STDERR, STDOUT)
68
68
  console = ActiveSupport::Logger.new(STDERR)
69
69
  console.level = Rails.logger.level
70
- Rails.logger = ActiveSupport::BroadcastLogger.new(Rails.logger, console)
70
+ Rails.logger.broadcast_to(console)
71
71
  end
72
72
  ActiveRecord.verbose_query_logs = false
73
73
  end
@@ -93,7 +93,7 @@ module ActiveRecord
93
93
  end
94
94
  end
95
95
 
96
- # Same as <tt>#count</tt> but perform the query asynchronously and returns an ActiveRecord::Promise
96
+ # Same as <tt>#count</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
97
97
  def async_count(column_name = nil)
98
98
  async.count(column_name)
99
99
  end
@@ -106,7 +106,7 @@ module ActiveRecord
106
106
  calculate(:average, column_name)
107
107
  end
108
108
 
109
- # Same as <tt>#average</tt> but perform the query asynchronously and returns an ActiveRecord::Promise
109
+ # Same as <tt>#average</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
110
110
  def async_average(column_name)
111
111
  async.average(column_name)
112
112
  end
@@ -120,7 +120,7 @@ module ActiveRecord
120
120
  calculate(:minimum, column_name)
121
121
  end
122
122
 
123
- # Same as <tt>#minimum</tt> but perform the query asynchronously and returns an ActiveRecord::Promise
123
+ # Same as <tt>#minimum</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
124
124
  def async_minimum(column_name)
125
125
  async.minimum(column_name)
126
126
  end
@@ -134,7 +134,7 @@ module ActiveRecord
134
134
  calculate(:maximum, column_name)
135
135
  end
136
136
 
137
- # Same as <tt>#maximum</tt> but perform the query asynchronously and returns an ActiveRecord::Promise
137
+ # Same as <tt>#maximum</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
138
138
  def async_maximum(column_name)
139
139
  async.maximum(column_name)
140
140
  end
@@ -152,7 +152,7 @@ module ActiveRecord
152
152
  end
153
153
  end
154
154
 
155
- # Same as <tt>#sum</tt> but perform the query asynchronously and returns an ActiveRecord::Promise
155
+ # Same as <tt>#sum</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
156
156
  def async_sum(identity_or_column = nil)
157
157
  async.sum(identity_or_column)
158
158
  end
@@ -287,7 +287,7 @@ module ActiveRecord
287
287
  end
288
288
  end
289
289
 
290
- # Same as <tt>#pluck</tt> but perform the query asynchronously and returns an ActiveRecord::Promise
290
+ # Same as <tt>#pluck</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
291
291
  def async_pluck(*column_names)
292
292
  async.pluck(*column_names)
293
293
  end
@@ -315,7 +315,7 @@ module ActiveRecord
315
315
  limit(1).pluck(*column_names).then(&:first)
316
316
  end
317
317
 
318
- # Same as <tt>#pick</tt> but perform the query asynchronously and returns an ActiveRecord::Promise
318
+ # Same as <tt>#pick</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
319
319
  def async_pick(*column_names)
320
320
  async.pick(*column_names)
321
321
  end
@@ -358,7 +358,7 @@ module ActiveRecord
358
358
  result.then { |result| type_cast_pluck_values(result, columns) }
359
359
  end
360
360
 
361
- # Same as <tt>#ids</tt> but perform the query asynchronously and returns an ActiveRecord::Promise
361
+ # Same as <tt>#ids</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
362
362
  def async_ids
363
363
  async.ids
364
364
  end
@@ -23,6 +23,7 @@ module ActiveRecord
23
23
  db_path = db_config.database
24
24
  file = File.absolute_path?(db_path) ? db_path : File.join(root, db_path)
25
25
  FileUtils.rm(file)
26
+ FileUtils.rm_f(["#{file}-shm", "#{file}-wal"])
26
27
  rescue Errno::ENOENT => error
27
28
  raise NoDatabaseError.new(error.message)
28
29
  end
@@ -87,7 +87,7 @@ module ActiveRecord
87
87
  klass.connection.schema_cache.indexes(klass.table_name).any? do |index|
88
88
  index.unique &&
89
89
  index.where.nil? &&
90
- (index.columns - attributes).empty?
90
+ (Array(index.columns) - attributes).empty?
91
91
  end
92
92
  end
93
93
 
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: 7.1.0.rc1
4
+ version: 7.1.0
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: 2023-09-27 00:00:00.000000000 Z
11
+ date: 2023-10-05 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: 7.1.0.rc1
19
+ version: 7.1.0
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: 7.1.0.rc1
26
+ version: 7.1.0
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: 7.1.0.rc1
33
+ version: 7.1.0
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: 7.1.0.rc1
40
+ version: 7.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: timeout
43
43
  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.0.rc1/activerecord/CHANGELOG.md
473
- documentation_uri: https://api.rubyonrails.org/v7.1.0.rc1/
472
+ changelog_uri: https://github.com/rails/rails/blob/v7.1.0/activerecord/CHANGELOG.md
473
+ documentation_uri: https://api.rubyonrails.org/v7.1.0/
474
474
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
475
- source_code_uri: https://github.com/rails/rails/tree/v7.1.0.rc1/activerecord
475
+ source_code_uri: https://github.com/rails/rails/tree/v7.1.0/activerecord
476
476
  rubygems_mfa_required: 'true'
477
477
  post_install_message:
478
478
  rdoc_options:
@@ -487,9 +487,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
487
487
  version: 2.7.0
488
488
  required_rubygems_version: !ruby/object:Gem::Requirement
489
489
  requirements:
490
- - - ">"
490
+ - - ">="
491
491
  - !ruby/object:Gem::Version
492
- version: 1.3.1
492
+ version: '0'
493
493
  requirements: []
494
494
  rubygems_version: 3.4.18
495
495
  signing_key: