activerecord 7.1.0 → 7.1.1

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: 8c1c4576a55f62b03c5c65f85726c7a054dcf2265c0596ab2b836366f70de537
4
- data.tar.gz: 8e1a2827cfc53bef1deaba5901134b589bac138711e37ac34fcf95254372b875
3
+ metadata.gz: 3595eee8065caff3100f00f5ce54d1b3a34935759766cb16b4d8229a57ebc97e
4
+ data.tar.gz: 5fbab431bcbc3b56cae5b2d8400c893071c72ccc7feea3eb6d9343418c650ec6
5
5
  SHA512:
6
- metadata.gz: 13a36c3bbd80622c3a266fd79883baa35dec93e3624d92718cc0fa56f6f4c23dfab83e6fd702e4a8e35b6e4a6f2e81fcc24f8c9e7a71c8d9e791f71bccb9536e
7
- data.tar.gz: 0b132373d4dda124cc61707c5cd9e08e5cabb68815ed8650de2250becc5d0856610b3622a0d18434bd5182d84cf31fb6b20117d5b0d8ef28ef7698fdcfcc28b4
6
+ metadata.gz: c75c3da922f3b0089112bb07c115787bedc1bb57a6e05aa04df893262554e09bf81e71898ac7ed24b1c80a00071818e14267cbffc2bb2b789755867b85f76d78
7
+ data.tar.gz: 5f6684e9a76e3a2a7156b687d4ac0701b9ddd840edd9c671f51031c534bdbd1e920b2aad65a479299383cb8555346a585e3167c353f33f95ecf8e05115438205
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## Rails 7.1.1 (October 11, 2023) ##
2
+
3
+ * Fix auto populating IDENTITY columns for PostgreSQL.
4
+
5
+ *fatkodima*
6
+
7
+ * Fix "ArgumentError: wrong number of arguments (given 3, expected 2)" when
8
+ down migrating `rename_table` in older migrations.
9
+
10
+ *fatkodima*
11
+
12
+ * Do not require the Action Text, Active Storage and Action Mailbox tables
13
+ to be present when running when running test on CI.
14
+
15
+ *Rafael Mendonça França*
16
+
17
+
1
18
  ## Rails 7.1.0 (October 05, 2023) ##
2
19
 
3
20
  * No changes.
@@ -7,7 +7,7 @@ module ActiveRecord
7
7
  # = Active Record Attribute Methods \Dirty
8
8
  #
9
9
  # Provides a way to track changes in your Active Record models. It adds all
10
- # methods from ActiveModel::Dirty and adds database specific methods.
10
+ # methods from ActiveModel::Dirty and adds database-specific methods.
11
11
  #
12
12
  # A newly created +Person+ object is unchanged:
13
13
  #
@@ -673,7 +673,7 @@ module ActiveRecord
673
673
 
674
674
  def extract_table_ref_from_insert_sql(sql)
675
675
  if sql =~ /into\s("[A-Za-z0-9_."\[\]\s]+"|[A-Za-z0-9_."\[\]]+)\s*/im
676
- $1.strip
676
+ $1.delete('"').strip
677
677
  end
678
678
  end
679
679
  end
@@ -983,7 +983,6 @@ module ActiveRecord
983
983
  # Adds a reference. The reference column is a bigint by default,
984
984
  # the <tt>:type</tt> option can be used to specify a different type.
985
985
  # Optionally adds a +_type+ column, if <tt>:polymorphic</tt> option is provided.
986
- # #add_reference and #add_belongs_to are acceptable.
987
986
  #
988
987
  # The +options+ hash can include the following keys:
989
988
  # [<tt>:type</tt>]
@@ -1034,7 +1033,6 @@ module ActiveRecord
1034
1033
  alias :add_belongs_to :add_reference
1035
1034
 
1036
1035
  # Removes the reference(s). Also removes a +type+ column if one exists.
1037
- # #remove_reference and #remove_belongs_to are acceptable.
1038
1036
  #
1039
1037
  # ====== Remove the reference
1040
1038
  #
@@ -1400,7 +1398,7 @@ module ActiveRecord
1400
1398
 
1401
1399
  limited = relation.reselect(values).distinct!
1402
1400
  limited_ids = select_rows(limited.arel, "SQL").map do |results|
1403
- results.last(Array(relation.primary_key).length) # ignores order values for MySQL and Postgres
1401
+ results.last(Array(relation.primary_key).length) # ignores order values for MySQL and PostgreSQL
1404
1402
  end
1405
1403
 
1406
1404
  if limited_ids.empty?
@@ -6,16 +6,24 @@ module ActiveRecord
6
6
  class Column < ConnectionAdapters::Column # :nodoc:
7
7
  delegate :oid, :fmod, to: :sql_type_metadata
8
8
 
9
- def initialize(*, serial: nil, generated: nil, **)
9
+ def initialize(*, serial: nil, identity: nil, generated: nil, **)
10
10
  super
11
11
  @serial = serial
12
+ @identity = identity
12
13
  @generated = generated
13
14
  end
14
15
 
16
+ def identity?
17
+ @identity
18
+ end
19
+
15
20
  def serial?
16
21
  @serial
17
22
  end
18
- alias_method :auto_incremented_by_db?, :serial?
23
+
24
+ def auto_incremented_by_db?
25
+ serial? || identity?
26
+ end
19
27
 
20
28
  def virtual?
21
29
  # We assume every generated column is virtual, no matter the concrete type
@@ -41,12 +49,14 @@ module ActiveRecord
41
49
 
42
50
  def init_with(coder)
43
51
  @serial = coder["serial"]
52
+ @identity = coder["identity"]
44
53
  @generated = coder["generated"]
45
54
  super
46
55
  end
47
56
 
48
57
  def encode_with(coder)
49
58
  coder["serial"] = @serial
59
+ coder["identity"] = @identity
50
60
  coder["generated"] = @generated
51
61
  super
52
62
  end
@@ -54,6 +64,7 @@ module ActiveRecord
54
64
  def ==(other)
55
65
  other.is_a?(Column) &&
56
66
  super &&
67
+ identity? == other.identity? &&
57
68
  serial? == other.serial?
58
69
  end
59
70
  alias :eql? :==
@@ -61,6 +72,7 @@ module ActiveRecord
61
72
  def hash
62
73
  Column.hash ^
63
74
  super.hash ^
75
+ identity?.hash ^
64
76
  serial?.hash
65
77
  end
66
78
  end
@@ -15,7 +15,7 @@ module ActiveRecord
15
15
  time = super
16
16
  return time if time.is_a?(ActiveSupport::TimeWithZone) || !time.acts_like?(:time)
17
17
 
18
- # While in UTC mode, the PG gem may not return times back in "UTC" even if they were provided to Postgres in UTC.
18
+ # While in UTC mode, the PG gem may not return times back in "UTC" even if they were provided to PostgreSQL in UTC.
19
19
  # We prefer times always in UTC, so here we convert back.
20
20
  if is_utc?
21
21
  time.getutc
@@ -908,7 +908,7 @@ module ActiveRecord
908
908
  end
909
909
 
910
910
  def new_column_from_field(table_name, field, _definitions)
911
- column_name, type, default, notnull, oid, fmod, collation, comment, attgenerated = field
911
+ column_name, type, default, notnull, oid, fmod, collation, comment, identity, attgenerated = field
912
912
  type_metadata = fetch_type_metadata(column_name, type, oid.to_i, fmod.to_i)
913
913
  default_value = extract_value_from_default(default)
914
914
 
@@ -931,6 +931,7 @@ module ActiveRecord
931
931
  collation: collation,
932
932
  comment: comment.presence,
933
933
  serial: serial,
934
+ identity: identity.presence,
934
935
  generated: attgenerated
935
936
  )
936
937
  end
@@ -1076,6 +1076,7 @@ module ActiveRecord
1076
1076
  SELECT a.attname, format_type(a.atttypid, a.atttypmod),
1077
1077
  pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
1078
1078
  c.collname, col_description(a.attrelid, a.attnum) AS comment,
1079
+ a.attidentity AS identity,
1079
1080
  #{supports_virtual_columns? ? 'attgenerated' : quote('')} as attgenerated
1080
1081
  FROM pg_attribute a
1081
1082
  LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
@@ -536,6 +536,27 @@ module ActiveRecord
536
536
  coder["active_record_yaml_version"] = 2
537
537
  end
538
538
 
539
+ ##
540
+ # :method: slice
541
+ #
542
+ # :call-seq: slice(*methods)
543
+ #
544
+ # Returns a hash of the given methods with their names as keys and returned
545
+ # values as values.
546
+ #
547
+ #--
548
+ # Implemented by ActiveModel::Access#slice.
549
+
550
+ ##
551
+ # :method: values_at
552
+ #
553
+ # :call-seq: values_at(*methods)
554
+ #
555
+ # Returns an array of the values returned by the given methods.
556
+ #
557
+ #--
558
+ # Implemented by ActiveModel::Access#values_at.
559
+
539
560
  # Returns true if +comparison_object+ is the same exact object, or +comparison_object+
540
561
  # is of the same type and +self+ has an ID and it is equal to +comparison_object.id+.
541
562
  #
@@ -701,27 +722,6 @@ module ActiveRecord
701
722
  end
702
723
  end
703
724
 
704
- ##
705
- # :method: values_at
706
- #
707
- # :call-seq: values_at(*methods)
708
- #
709
- # Returns an array of the values returned by the given methods.
710
- #
711
- #--
712
- # Implemented by ActiveModel::Access#values_at.
713
-
714
- ##
715
- # :method: slice
716
- #
717
- # :call-seq: slice(*methods)
718
- #
719
- # Returns a hash of the given methods with their names as keys and returned
720
- # values as values.
721
- #
722
- #--
723
- # Implemented by ActiveModel::Access#slice.
724
-
725
725
  private
726
726
  # +Array#flatten+ will call +#to_ary+ (recursively) on each of the elements of
727
727
  # the array, and then rescues from the possible +NoMethodError+. If those elements are
@@ -9,7 +9,7 @@ module ActiveRecord
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 1
12
- TINY = 0
12
+ TINY = 1
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
@@ -64,6 +64,8 @@ module ActiveRecord
64
64
  end
65
65
 
66
66
  def create_table_and_set_flags(environment, schema_sha1 = nil)
67
+ return unless enabled?
68
+
67
69
  create_table
68
70
  update_or_create_entry(:environment, environment)
69
71
  update_or_create_entry(:schema_sha1, schema_sha1) if schema_sha1
@@ -206,7 +206,10 @@ module ActiveRecord
206
206
  end
207
207
 
208
208
  def invert_rename_table(args)
209
- [:rename_table, args.reverse]
209
+ old_name, new_name, options = args
210
+ args = [new_name, old_name]
211
+ args << options if options
212
+ [:rename_table, args]
210
213
  end
211
214
 
212
215
  def invert_remove_column(args)
@@ -283,13 +283,11 @@ module ActiveRecord
283
283
  #
284
284
  # === Creating forms with nested attributes
285
285
  #
286
- # Use ActionView::Helpers::FormHelper#fields_for to create form elements
287
- # for updating or destroying nested attributes.
286
+ # Use ActionView::Helpers::FormHelper#fields_for to create form elements for
287
+ # nested attributes.
288
288
  #
289
- # === Testing
290
- #
291
- # If you are using ActionView::Helpers::FormHelper#fields_for, your integration
292
- # tests should replicate the HTML structure it provides. For example;
289
+ # Integration test params should reflect the structure of the form. For
290
+ # example:
293
291
  #
294
292
  # post members_path, params: {
295
293
  # member: {
@@ -398,7 +398,7 @@ To keep using the current cache store, you can turn off cache versioning entirel
398
398
  end
399
399
 
400
400
  ActiveSupport.on_load(:active_record_fixture_set) do
401
- # Encrypt active record fixtures
401
+ # Encrypt Active Record fixtures
402
402
  if ActiveRecord::Encryption.config.encrypt_fixtures
403
403
  ActiveRecord::Fixture.prepend ActiveRecord::Encryption::EncryptedFixtures
404
404
  end
@@ -93,7 +93,8 @@ 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 #count, but performs the query asynchronously and returns an
97
+ # ActiveRecord::Promise.
97
98
  def async_count(column_name = nil)
98
99
  async.count(column_name)
99
100
  end
@@ -106,7 +107,8 @@ module ActiveRecord
106
107
  calculate(:average, column_name)
107
108
  end
108
109
 
109
- # Same as <tt>#average</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
110
+ # Same as #average, but performs the query asynchronously and returns an
111
+ # ActiveRecord::Promise.
110
112
  def async_average(column_name)
111
113
  async.average(column_name)
112
114
  end
@@ -120,7 +122,8 @@ module ActiveRecord
120
122
  calculate(:minimum, column_name)
121
123
  end
122
124
 
123
- # Same as <tt>#minimum</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
125
+ # Same as #minimum, but performs the query asynchronously and returns an
126
+ # ActiveRecord::Promise.
124
127
  def async_minimum(column_name)
125
128
  async.minimum(column_name)
126
129
  end
@@ -134,7 +137,8 @@ module ActiveRecord
134
137
  calculate(:maximum, column_name)
135
138
  end
136
139
 
137
- # Same as <tt>#maximum</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
140
+ # Same as #maximum, but performs the query asynchronously and returns an
141
+ # ActiveRecord::Promise.
138
142
  def async_maximum(column_name)
139
143
  async.maximum(column_name)
140
144
  end
@@ -152,7 +156,8 @@ module ActiveRecord
152
156
  end
153
157
  end
154
158
 
155
- # Same as <tt>#sum</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
159
+ # Same as #sum, but performs the query asynchronously and returns an
160
+ # ActiveRecord::Promise.
156
161
  def async_sum(identity_or_column = nil)
157
162
  async.sum(identity_or_column)
158
163
  end
@@ -287,7 +292,8 @@ module ActiveRecord
287
292
  end
288
293
  end
289
294
 
290
- # Same as <tt>#pluck</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
295
+ # Same as #pluck, but performs the query asynchronously and returns an
296
+ # ActiveRecord::Promise.
291
297
  def async_pluck(*column_names)
292
298
  async.pluck(*column_names)
293
299
  end
@@ -315,7 +321,8 @@ module ActiveRecord
315
321
  limit(1).pluck(*column_names).then(&:first)
316
322
  end
317
323
 
318
- # Same as <tt>#pick</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
324
+ # Same as #pick, but performs the query asynchronously and returns an
325
+ # ActiveRecord::Promise.
319
326
  def async_pick(*column_names)
320
327
  async.pick(*column_names)
321
328
  end
@@ -358,7 +365,8 @@ module ActiveRecord
358
365
  result.then { |result| type_cast_pluck_values(result, columns) }
359
366
  end
360
367
 
361
- # Same as <tt>#ids</tt> but perform the query asynchronously and returns an ActiveRecord::Promise.
368
+ # Same as #ids, but performs the query asynchronously and returns an
369
+ # ActiveRecord::Promise.
362
370
  def async_ids
363
371
  async.ids
364
372
  end
@@ -588,7 +588,7 @@ module ActiveRecord
588
588
  # User.order(Arel.sql('end_date - start_date'))
589
589
  # # SELECT "users".* FROM "users" ORDER BY end_date - start_date
590
590
  #
591
- # Custom query syntax, like JSON columns for Postgres, is supported in this way.
591
+ # Custom query syntax, like JSON columns for PostgreSQL, is supported in this way.
592
592
  #
593
593
  # User.order(Arel.sql("payload->>'kind'"))
594
594
  # # SELECT "users".* FROM "users" ORDER BY payload->>'kind'
@@ -30,7 +30,7 @@ module ActiveRecord
30
30
  #
31
31
  # ActiveRecord::Base.time_zone_aware_types = [:datetime]
32
32
  #
33
- # You can also add database specific timezone aware types. For example, for PostgreSQL:
33
+ # You can also add database-specific timezone aware types. For example, for PostgreSQL:
34
34
  #
35
35
  # ActiveRecord::Base.time_zone_aware_types += [:tsrange, :tstzrange]
36
36
  #
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
4
+ version: 7.1.1
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-10-05 00:00:00.000000000 Z
11
+ date: 2023-10-11 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
19
+ version: 7.1.1
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
26
+ version: 7.1.1
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
33
+ version: 7.1.1
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
40
+ version: 7.1.1
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/activerecord/CHANGELOG.md
473
- documentation_uri: https://api.rubyonrails.org/v7.1.0/
472
+ changelog_uri: https://github.com/rails/rails/blob/v7.1.1/activerecord/CHANGELOG.md
473
+ documentation_uri: https://api.rubyonrails.org/v7.1.1/
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/activerecord
475
+ source_code_uri: https://github.com/rails/rails/tree/v7.1.1/activerecord
476
476
  rubygems_mfa_required: 'true'
477
477
  post_install_message:
478
478
  rdoc_options: