activerecord 6.0.2.2 → 6.0.3.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activerecord might be problematic. Click here for more details.

Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +66 -0
  3. data/README.rdoc +1 -1
  4. data/lib/active_record.rb +1 -0
  5. data/lib/active_record/advisory_lock_base.rb +18 -0
  6. data/lib/active_record/aggregations.rb +0 -1
  7. data/lib/active_record/association_relation.rb +4 -11
  8. data/lib/active_record/associations.rb +1 -1
  9. data/lib/active_record/associations/alias_tracker.rb +0 -1
  10. data/lib/active_record/associations/association.rb +5 -9
  11. data/lib/active_record/associations/builder/has_and_belongs_to_many.rb +0 -2
  12. data/lib/active_record/associations/collection_proxy.rb +1 -2
  13. data/lib/active_record/associations/has_many_association.rb +0 -1
  14. data/lib/active_record/associations/join_dependency.rb +9 -0
  15. data/lib/active_record/associations/preloader.rb +0 -1
  16. data/lib/active_record/attribute_assignment.rb +0 -1
  17. data/lib/active_record/attribute_decorators.rb +0 -2
  18. data/lib/active_record/attribute_methods/before_type_cast.rb +0 -1
  19. data/lib/active_record/attribute_methods/dirty.rb +2 -2
  20. data/lib/active_record/attribute_methods/primary_key.rb +0 -2
  21. data/lib/active_record/attribute_methods/read.rb +0 -1
  22. data/lib/active_record/attribute_methods/serialization.rb +0 -1
  23. data/lib/active_record/attribute_methods/time_zone_conversion.rb +0 -2
  24. data/lib/active_record/attribute_methods/write.rb +0 -1
  25. data/lib/active_record/attributes.rb +0 -1
  26. data/lib/active_record/autosave_association.rb +3 -3
  27. data/lib/active_record/callbacks.rb +1 -2
  28. data/lib/active_record/coders/yaml_column.rb +0 -1
  29. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +0 -3
  30. data/lib/active_record/connection_adapters/abstract/database_statements.rb +17 -15
  31. data/lib/active_record/connection_adapters/abstract/query_cache.rb +0 -1
  32. data/lib/active_record/connection_adapters/abstract/schema_creation.rb +1 -2
  33. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +27 -27
  34. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +47 -30
  35. data/lib/active_record/connection_adapters/abstract/transaction.rb +4 -5
  36. data/lib/active_record/connection_adapters/abstract_adapter.rb +7 -3
  37. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +12 -28
  38. data/lib/active_record/connection_adapters/connection_specification.rb +1 -2
  39. data/lib/active_record/connection_adapters/mysql/column.rb +1 -1
  40. data/lib/active_record/connection_adapters/mysql/database_statements.rb +5 -11
  41. data/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb +0 -1
  42. data/lib/active_record/connection_adapters/mysql/schema_creation.rb +1 -2
  43. data/lib/active_record/connection_adapters/mysql/schema_statements.rb +8 -8
  44. data/lib/active_record/connection_adapters/mysql2_adapter.rb +0 -1
  45. data/lib/active_record/connection_adapters/postgresql/database_statements.rb +6 -2
  46. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +0 -1
  47. data/lib/active_record/connection_adapters/postgresql/oid/enum.rb +0 -1
  48. data/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +0 -1
  49. data/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb +0 -1
  50. data/lib/active_record/connection_adapters/postgresql/oid/oid.rb +1 -1
  51. data/lib/active_record/connection_adapters/postgresql/oid/point.rb +0 -1
  52. data/lib/active_record/connection_adapters/postgresql/oid/range.rb +0 -1
  53. data/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb +1 -1
  54. data/lib/active_record/connection_adapters/postgresql/oid/uuid.rb +0 -1
  55. data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +1 -1
  56. data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +2 -2
  57. data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +1 -1
  58. data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +0 -1
  59. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +15 -29
  60. data/lib/active_record/connection_adapters/postgresql/utils.rb +0 -1
  61. data/lib/active_record/connection_adapters/postgresql_adapter.rb +5 -2
  62. data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +5 -6
  63. data/lib/active_record/connection_adapters/sqlite3/quoting.rb +0 -1
  64. data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +3 -3
  65. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +8 -7
  66. data/lib/active_record/connection_adapters/statement_pool.rb +0 -1
  67. data/lib/active_record/connection_handling.rb +10 -26
  68. data/lib/active_record/core.rb +0 -2
  69. data/lib/active_record/counter_cache.rb +4 -1
  70. data/lib/active_record/database_configurations/url_config.rb +0 -1
  71. data/lib/active_record/dynamic_matchers.rb +2 -3
  72. data/lib/active_record/explain.rb +0 -1
  73. data/lib/active_record/fixture_set/table_row.rb +0 -1
  74. data/lib/active_record/fixture_set/table_rows.rb +0 -1
  75. data/lib/active_record/fixtures.rb +0 -3
  76. data/lib/active_record/gem_version.rb +2 -2
  77. data/lib/active_record/inheritance.rb +0 -3
  78. data/lib/active_record/insert_all.rb +3 -3
  79. data/lib/active_record/internal_metadata.rb +1 -1
  80. data/lib/active_record/locking/optimistic.rb +0 -1
  81. data/lib/active_record/log_subscriber.rb +1 -1
  82. data/lib/active_record/middleware/database_selector.rb +0 -1
  83. data/lib/active_record/middleware/database_selector/resolver.rb +1 -2
  84. data/lib/active_record/migration.rb +4 -4
  85. data/lib/active_record/migration/command_recorder.rb +6 -18
  86. data/lib/active_record/migration/compatibility.rb +3 -3
  87. data/lib/active_record/migration/join_table.rb +0 -1
  88. data/lib/active_record/model_schema.rb +0 -2
  89. data/lib/active_record/nested_attributes.rb +0 -2
  90. data/lib/active_record/no_touching.rb +2 -2
  91. data/lib/active_record/null_relation.rb +0 -1
  92. data/lib/active_record/persistence.rb +4 -5
  93. data/lib/active_record/querying.rb +1 -1
  94. data/lib/active_record/railtie.rb +1 -1
  95. data/lib/active_record/railties/collection_cache_association_loading.rb +1 -1
  96. data/lib/active_record/reflection.rb +8 -8
  97. data/lib/active_record/relation.rb +12 -1
  98. data/lib/active_record/relation/batches.rb +0 -1
  99. data/lib/active_record/relation/calculations.rb +1 -1
  100. data/lib/active_record/relation/delegation.rb +7 -6
  101. data/lib/active_record/relation/finder_methods.rb +0 -1
  102. data/lib/active_record/relation/from_clause.rb +4 -0
  103. data/lib/active_record/relation/merger.rb +0 -1
  104. data/lib/active_record/relation/predicate_builder.rb +1 -5
  105. data/lib/active_record/relation/query_methods.rb +9 -7
  106. data/lib/active_record/relation/spawn_methods.rb +0 -1
  107. data/lib/active_record/relation/where_clause.rb +0 -1
  108. data/lib/active_record/result.rb +0 -1
  109. data/lib/active_record/schema_migration.rb +1 -1
  110. data/lib/active_record/scoping.rb +0 -1
  111. data/lib/active_record/scoping/default.rb +0 -1
  112. data/lib/active_record/scoping/named.rb +3 -4
  113. data/lib/active_record/store.rb +1 -1
  114. data/lib/active_record/suppressor.rb +2 -2
  115. data/lib/active_record/table_metadata.rb +16 -1
  116. data/lib/active_record/tasks/mysql_database_tasks.rb +0 -1
  117. data/lib/active_record/tasks/postgresql_database_tasks.rb +0 -1
  118. data/lib/active_record/tasks/sqlite_database_tasks.rb +0 -1
  119. data/lib/active_record/test_fixtures.rb +1 -1
  120. data/lib/active_record/timestamp.rb +0 -1
  121. data/lib/active_record/touch_later.rb +1 -2
  122. data/lib/active_record/transactions.rb +8 -8
  123. data/lib/active_record/type.rb +0 -1
  124. data/lib/active_record/type/adapter_specific_registry.rb +2 -5
  125. data/lib/active_record/type/hash_lookup_type_map.rb +0 -1
  126. data/lib/active_record/type/serialized.rb +0 -1
  127. data/lib/active_record/type/type_map.rb +0 -1
  128. data/lib/active_record/type/unsigned_integer.rb +0 -1
  129. data/lib/active_record/validations.rb +2 -3
  130. data/lib/active_record/validations/associated.rb +1 -2
  131. data/lib/arel.rb +5 -1
  132. data/lib/arel/predications.rb +5 -6
  133. data/lib/arel/visitors/depth_first.rb +0 -1
  134. data/lib/arel/visitors/dot.rb +0 -1
  135. data/lib/arel/visitors/mssql.rb +0 -1
  136. data/lib/arel/visitors/oracle.rb +1 -2
  137. data/lib/arel/visitors/oracle12.rb +0 -1
  138. data/lib/arel/visitors/postgresql.rb +0 -1
  139. data/lib/arel/visitors/sqlite.rb +0 -1
  140. data/lib/arel/visitors/to_sql.rb +0 -1
  141. data/lib/arel/visitors/visitor.rb +0 -1
  142. data/lib/arel/visitors/where_sql.rb +0 -1
  143. data/lib/rails/generators/active_record/application_record/application_record_generator.rb +0 -1
  144. data/lib/rails/generators/active_record/migration.rb +0 -1
  145. data/lib/rails/generators/active_record/migration/templates/migration.rb.tt +1 -1
  146. data/lib/rails/generators/active_record/model/model_generator.rb +0 -1
  147. metadata +14 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c3588da1105145a803b938c41fcd2f6053a6c5bb995b6d2b5d5c0692b73a7a9
4
- data.tar.gz: 5c57f45f3d17427d3bb55fda6213705e9246f7bb41699990e2b717ea3e165da4
3
+ metadata.gz: 6ccce92664ea2ffdf668e08bd901b85522987ff1bb9eab653e7c46c46919788b
4
+ data.tar.gz: 66f3751f03d187d4275389d818904f9ac09d762ecaddae82a5f65a8b50abde94
5
5
  SHA512:
6
- metadata.gz: ada655dc33878d1ed91b8b5ec035f6c65d0fb6be9b1c92e9f72afc51105a9141a101451584d1c0a7fafefc76d42c7ae4a5349f5eaad18ca69b539f74eed9d2ae
7
- data.tar.gz: b285f57dcf0dd6e5b24c4973978e471afd521826c7d62f4e83293827dbf34c1c5d9efa49d87f56d935040bc9ffdc9291eb4d8c5e7a47d8cc5bb281ec4e6c1480
6
+ metadata.gz: 9c0002b9ff699757fb3178bb15f1237a64447a9b5a5af2b7c155bba9e723b0df02ca86499d2a782da561ae4b798c65aa523ffd4ff626fdbbf3763575bc1913a1
7
+ data.tar.gz: aab48d472ef1ed54a7a0089378834ab5911d9fe5266d5a068e08f12fa4f900b45da06dbb1879f6d2d1d2c637be854f1af113d87e5846e847ca7a4d85855a6f36
@@ -1,3 +1,69 @@
1
+ ## Rails 6.0.3.rc1 (April 30, 2020) ##
2
+
3
+ * Recommend applications don't use the `database` kwarg in `connected_to`
4
+
5
+ The database kwarg in `connected_to` was meant to be used for one-off scripts but is often used in requests. This is really dangerous because it re-establishes a connection every time. It's deprecated in 6.1 and will be removed in 6.2 without replacement. This change soft deprecates it in 6.0 by removing documentation.
6
+
7
+ *Eileen M. Uchitelle*
8
+
9
+ * Fix support for PostgreSQL 11+ partitioned indexes.
10
+
11
+ *Sebastián Palma*
12
+
13
+ * Add support for beginless ranges, introduced in Ruby 2.7.
14
+
15
+ *Josh Goodall*
16
+
17
+ * Fix insert_all with enum values
18
+
19
+ Fixes #38716.
20
+
21
+ *Joel Blum*
22
+
23
+ * Regexp-escape table name for MS SQL
24
+
25
+ Add `Regexp.escape` to one method in ActiveRecord, so that table names with regular expression characters in them work as expected. Since MS SQL Server uses "[" and "]" to quote table and column names, and those characters are regular expression characters, methods like `pluck` and `select` fail in certain cases when used with the MS SQL Server adapter.
26
+
27
+ *Larry Reid*
28
+
29
+ * Store advisory locks on their own named connection.
30
+
31
+ Previously advisory locks were taken out against a connection when a migration started. This works fine in single database applications but doesn't work well when migrations need to open new connections which results in the lock getting dropped.
32
+
33
+ In order to fix this we are storing the advisory lock on a new connection with the connection specification name `AdisoryLockBase`. The caveat is that we need to maintain at least 2 connections to a database while migrations are running in order to do this.
34
+
35
+ *Eileen M. Uchitelle*, *John Crepezzi*
36
+
37
+ * Ensure `:reading` connections always raise if a write is attempted.
38
+
39
+ Now Rails will raise an `ActiveRecord::ReadOnlyError` if any connection on the reading handler attempts to make a write. If your reading role needs to write you should name the role something other than `:reading`.
40
+
41
+ *Eileen M. Uchitelle*
42
+
43
+ * Enforce fresh ETag header after a collection's contents change by adding
44
+ ActiveRecord::Relation#cache_key_with_version. This method will be used by
45
+ ActionController::ConditionalGet to ensure that when collection cache versioning
46
+ is enabled, requests using ConditionalGet don't return the same ETag header
47
+ after a collection is modified. Fixes #38078.
48
+
49
+ *Aaron Lipman*
50
+
51
+ * A database URL can now contain a querystring value that contains an equal sign. This is needed to support passing PostgresSQL `options`.
52
+
53
+ *Joshua Flanagan*
54
+
55
+ * Retain explicit selections on the base model after applying `includes` and `joins`.
56
+
57
+ Resolves #34889.
58
+
59
+ *Patrick Rebsch*
60
+
61
+
62
+ ## Rails 6.0.2.2 (March 19, 2020) ##
63
+
64
+ * No changes.
65
+
66
+
1
67
  ## Rails 6.0.2.1 (December 18, 2019) ##
2
68
 
3
69
  * No changes.
@@ -216,4 +216,4 @@ Bug reports for the Ruby on Rails project can be filed here:
216
216
 
217
217
  Feature requests should be discussed on the rails-core mailing list here:
218
218
 
219
- * https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core
219
+ * https://discuss.rubyonrails.org/c/rubyonrails-core
@@ -35,6 +35,7 @@ require "active_model/attribute_set"
35
35
  module ActiveRecord
36
36
  extend ActiveSupport::Autoload
37
37
 
38
+ autoload :AdvisoryLockBase
38
39
  autoload :Base
39
40
  autoload :Callbacks
40
41
  autoload :Core
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ # This class is used to create a connection that we can use for advisory
5
+ # locks. This will take out a "global" lock that can't be accidentally
6
+ # removed if a new connection is established during a migration.
7
+ class AdvisoryLockBase < ActiveRecord::Base # :nodoc:
8
+ self.abstract_class = true
9
+
10
+ self.connection_specification_name = "AdvisoryLockBase"
11
+
12
+ class << self
13
+ def _internal?
14
+ true
15
+ end
16
+ end
17
+ end
18
+ end
@@ -14,7 +14,6 @@ module ActiveRecord
14
14
  end
15
15
 
16
16
  private
17
-
18
17
  def clear_aggregation_cache
19
18
  @aggregation_cache.clear if persisted?
20
19
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module ActiveRecord
4
4
  class AssociationRelation < Relation
5
- def initialize(klass, association)
5
+ def initialize(klass, association, **)
6
6
  super(klass)
7
7
  @association = association
8
8
  end
@@ -17,28 +17,21 @@ module ActiveRecord
17
17
 
18
18
  def build(attributes = nil, &block)
19
19
  block = _deprecated_scope_block("new", &block)
20
- @association.scoping(self) do
21
- @association.build(attributes, &block)
22
- end
20
+ scoping { @association.build(attributes, &block) }
23
21
  end
24
22
  alias new build
25
23
 
26
24
  def create(attributes = nil, &block)
27
25
  block = _deprecated_scope_block("create", &block)
28
- @association.scoping(self) do
29
- @association.create(attributes, &block)
30
- end
26
+ scoping { @association.create(attributes, &block) }
31
27
  end
32
28
 
33
29
  def create!(attributes = nil, &block)
34
30
  block = _deprecated_scope_block("create!", &block)
35
- @association.scoping(self) do
36
- @association.create!(attributes, &block)
37
- end
31
+ scoping { @association.create!(attributes, &block) }
38
32
  end
39
33
 
40
34
  private
41
-
42
35
  def exec_queries
43
36
  super do |record|
44
37
  @association.set_inverse_instance_from_queries(record)
@@ -1857,7 +1857,7 @@ module ActiveRecord
1857
1857
  hm_options[k] = options[k] if options.key? k
1858
1858
  end
1859
1859
 
1860
- has_many name, scope, hm_options, &extension
1860
+ has_many name, scope, **hm_options, &extension
1861
1861
  _reflections[name.to_s].parent_reflection = habtm_reflection
1862
1862
  end
1863
1863
  end
@@ -72,7 +72,6 @@ module ActiveRecord
72
72
  attr_reader :aliases
73
73
 
74
74
  private
75
-
76
75
  def truncate(name)
77
76
  name.slice(0, @connection.table_alias_length - 2)
78
77
  end
@@ -43,7 +43,6 @@ module ActiveRecord
43
43
  reflection.check_validity!
44
44
 
45
45
  @owner, @reflection = owner, reflection
46
- @_scope = nil
47
46
 
48
47
  reset
49
48
  reset_scope
@@ -96,7 +95,11 @@ module ActiveRecord
96
95
  end
97
96
 
98
97
  def scope
99
- @_scope&.spawn || target_scope.merge!(association_scope)
98
+ if (scope = klass.current_scope) && scope.try(:proxy_association) == self
99
+ scope.spawn
100
+ else
101
+ target_scope.merge!(association_scope)
102
+ end
100
103
  end
101
104
 
102
105
  def reset_scope
@@ -196,13 +199,6 @@ module ActiveRecord
196
199
  _create_record(attributes, true, &block)
197
200
  end
198
201
 
199
- def scoping(relation, &block)
200
- @_scope = relation
201
- relation.scoping(&block)
202
- ensure
203
- @_scope = nil
204
- end
205
-
206
202
  private
207
203
  def find_target
208
204
  scope = self.scope
@@ -46,7 +46,6 @@ module ActiveRecord::Associations::Builder # :nodoc:
46
46
  end
47
47
 
48
48
  private
49
-
50
49
  def self.suppress_composite_primary_key(pk)
51
50
  pk unless pk.is_a?(Array)
52
51
  end
@@ -73,7 +72,6 @@ module ActiveRecord::Associations::Builder # :nodoc:
73
72
  end
74
73
 
75
74
  private
76
-
77
75
  def middle_options(join_model)
78
76
  middle_options = {}
79
77
  middle_options[:class_name] = "#{lhs_model.name}::#{join_model.name}"
@@ -27,7 +27,7 @@ module ActiveRecord
27
27
  # is computed directly through SQL and does not trigger by itself the
28
28
  # instantiation of the actual post records.
29
29
  class CollectionProxy < Relation
30
- def initialize(klass, association) #:nodoc:
30
+ def initialize(klass, association, **) #:nodoc:
31
31
  @association = association
32
32
  super klass
33
33
 
@@ -1101,7 +1101,6 @@ module ActiveRecord
1101
1101
  delegate(*delegate_methods, to: :scope)
1102
1102
 
1103
1103
  private
1104
-
1105
1104
  def find_nth_with_limit(index, limit)
1106
1105
  load_target if find_from_target?
1107
1106
  super
@@ -37,7 +37,6 @@ module ActiveRecord
37
37
  end
38
38
 
39
39
  private
40
-
41
40
  # Returns the number of records in this collection.
42
41
  #
43
42
  # If the association has a counter cache it gets that value. Otherwise
@@ -105,7 +105,9 @@ module ActiveRecord
105
105
 
106
106
  model_cache = Hash.new { |h, klass| h[klass] = {} }
107
107
  parents = model_cache[join_root]
108
+
108
109
  column_aliases = aliases.column_aliases join_root
110
+ column_aliases += explicit_selections(column_aliases, result_set)
109
111
 
110
112
  message_bus = ActiveSupport::Notifications.instrumenter
111
113
 
@@ -135,6 +137,13 @@ module ActiveRecord
135
137
  private
136
138
  attr_reader :alias_tracker
137
139
 
140
+ def explicit_selections(root_column_aliases, result_set)
141
+ root_names = root_column_aliases.map(&:name).to_set
142
+ result_set.columns
143
+ .reject { |n| root_names.include?(n) || n =~ /\At\d+_r\d+\z/ }
144
+ .map { |n| Aliases::Column.new(n, n) }
145
+ end
146
+
138
147
  def aliases
139
148
  @aliases ||= Aliases.new join_root.each_with_index.map { |join_part, i|
140
149
  columns = join_part.column_names.each_with_index.map { |column_name, j|
@@ -95,7 +95,6 @@ module ActiveRecord
95
95
  end
96
96
 
97
97
  private
98
-
99
98
  # Loads all the given data into +records+ for the +association+.
100
99
  def preloaders_on(association, records, scope, polymorphic_parent = false)
101
100
  case association
@@ -7,7 +7,6 @@ module ActiveRecord
7
7
  include ActiveModel::AttributeAssignment
8
8
 
9
9
  private
10
-
11
10
  def _assign_attributes(attributes)
12
11
  multi_parameter_attributes = {}
13
12
  nested_parameter_attributes = {}
@@ -46,7 +46,6 @@ module ActiveRecord
46
46
  end
47
47
 
48
48
  private
49
-
50
49
  def load_schema!
51
50
  super
52
51
  attribute_types.each do |name, type|
@@ -75,7 +74,6 @@ module ActiveRecord
75
74
  end
76
75
 
77
76
  private
78
-
79
77
  def decorators_for(name, type)
80
78
  matching(name, type).map(&:last)
81
79
  end
@@ -66,7 +66,6 @@ module ActiveRecord
66
66
  end
67
67
 
68
68
  private
69
-
70
69
  # Dispatch target for <tt>*_before_type_cast</tt> attribute methods.
71
70
  def attribute_before_type_cast(attribute_name)
72
71
  read_attribute_before_type_cast(attribute_name)
@@ -49,7 +49,7 @@ module ActiveRecord
49
49
  # +to+ When passed, this method will return false unless the value was
50
50
  # changed to the given value
51
51
  def saved_change_to_attribute?(attr_name, **options)
52
- mutations_before_last_save.changed?(attr_name.to_s, options)
52
+ mutations_before_last_save.changed?(attr_name.to_s, **options)
53
53
  end
54
54
 
55
55
  # Returns the change to an attribute during the last save. If the
@@ -99,7 +99,7 @@ module ActiveRecord
99
99
  # +to+ When passed, this method will return false unless the value will be
100
100
  # changed to the given value
101
101
  def will_save_change_to_attribute?(attr_name, **options)
102
- mutations_from_database.changed?(attr_name.to_s, options)
102
+ mutations_from_database.changed?(attr_name.to_s, **options)
103
103
  end
104
104
 
105
105
  # Returns the change to an attribute that will be persisted during the
@@ -45,7 +45,6 @@ module ActiveRecord
45
45
  end
46
46
 
47
47
  private
48
-
49
48
  def attribute_method?(attr_name)
50
49
  attr_name == "id" || super
51
50
  end
@@ -120,7 +119,6 @@ module ActiveRecord
120
119
  end
121
120
 
122
121
  private
123
-
124
122
  def suppress_composite_primary_key(pk)
125
123
  return pk unless pk.is_a?(Array)
126
124
 
@@ -7,7 +7,6 @@ module ActiveRecord
7
7
 
8
8
  module ClassMethods # :nodoc:
9
9
  private
10
-
11
10
  def define_method_attribute(name)
12
11
  ActiveModel::AttributeMethods::AttrNames.define_attribute_accessor_method(
13
12
  generated_attribute_methods, name
@@ -79,7 +79,6 @@ module ActiveRecord
79
79
  end
80
80
 
81
81
  private
82
-
83
82
  def type_incompatible_with_serialize?(type, class_name)
84
83
  type.is_a?(ActiveRecord::Type::Json) && class_name == ::JSON ||
85
84
  type.respond_to?(:type_cast_array, true) && class_name == ::Array
@@ -25,7 +25,6 @@ module ActiveRecord
25
25
  end
26
26
 
27
27
  private
28
-
29
28
  def convert_time_to_time_zone(value)
30
29
  return if value.nil?
31
30
 
@@ -64,7 +63,6 @@ module ActiveRecord
64
63
 
65
64
  module ClassMethods # :nodoc:
66
65
  private
67
-
68
66
  def inherited(subclass)
69
67
  super
70
68
  # We need to apply this decorator here, rather than on module inclusion. The closure
@@ -11,7 +11,6 @@ module ActiveRecord
11
11
 
12
12
  module ClassMethods # :nodoc:
13
13
  private
14
-
15
14
  def define_method_attribute=(name)
16
15
  ActiveModel::AttributeMethods::AttrNames.define_attribute_accessor_method(
17
16
  generated_attribute_methods, name, writer: true,
@@ -255,7 +255,6 @@ module ActiveRecord
255
255
  end
256
256
 
257
257
  private
258
-
259
258
  NO_DEFAULT_PROVIDED = Object.new # :nodoc:
260
259
  private_constant :NO_DEFAULT_PROVIDED
261
260
 
@@ -147,7 +147,6 @@ module ActiveRecord
147
147
 
148
148
  module ClassMethods # :nodoc:
149
149
  private
150
-
151
150
  def define_non_cyclic_method(name, &block)
152
151
  return if instance_methods(false).include?(name)
153
152
  define_method(name) do |*args|
@@ -267,7 +266,6 @@ module ActiveRecord
267
266
  end
268
267
 
269
268
  private
270
-
271
269
  # Returns the record for an association collection that should be validated
272
270
  # or saved. If +autosave+ is +false+ only new records will be returned,
273
271
  # unless the parent is/was a new record itself.
@@ -363,7 +361,9 @@ module ActiveRecord
363
361
  # Is used as a before_save callback to check while saving a collection
364
362
  # association whether or not the parent was a new record before saving.
365
363
  def before_save_collection_association
366
- @new_record_before_save = new_record?
364
+ unless defined?(@new_record_before_save)
365
+ @new_record_before_save = new_record?
366
+ end
367
367
  end
368
368
 
369
369
  def after_save_collection_association
@@ -314,7 +314,7 @@ module ActiveRecord
314
314
  @_destroy_callback_already_called = false
315
315
  end
316
316
 
317
- def touch(*) #:nodoc:
317
+ def touch(*, **) #:nodoc:
318
318
  _run_touch_callbacks { super }
319
319
  end
320
320
 
@@ -323,7 +323,6 @@ module ActiveRecord
323
323
  end
324
324
 
325
325
  private
326
-
327
326
  def create_or_update(**)
328
327
  _run_save_callbacks { super }
329
328
  end