activerecord 6.1.0.rc2 → 6.1.0

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b093236482caac43173dfffd7096282d55d6fc0099ed9f6e684b84efabfbb466
4
- data.tar.gz: ef623a179fbabb3fd9aa544baf87da3bf342cca09dd6a2bf9bd3f4d2435410a8
3
+ metadata.gz: 418812373f3ff5fd16133fe0928b94b80b78b8a366abfc23a205fcb2ccc5a3e3
4
+ data.tar.gz: 70db1902a8fc82b1c46f8a7731ffb358357bc8cac29564a57881a732dbd2a65a
5
5
  SHA512:
6
- metadata.gz: 3ba3873e17ac4ad32e19d81a7669b24024195986c8cbbf9eb54ae9ecf798d9f82369594051712609458bf84f4bb58228c0dfcef9ce21cb8926dd07dd898efaba
7
- data.tar.gz: 8fadd55a99b48ba91ec273fc76d24d3257d67c89999fde3851547b29711244b649edccbeb9c4ff9ba326348a61be4da361fd49f35dcd55109c19ada385f47de6
6
+ metadata.gz: 31ae64f629cb62f63bc37c74a888d557f9f0b102d401f2f9cf62c7d31655d99e5161ae9bc7f8be874c7a9cf27ec879dde3c04075df5cb2b5868891c0db144a50
7
+ data.tar.gz: cfc9585f3a6f53187707a9d96503269e3d4b1c5f1fe8c5f4db3bdefe8ce636042b6cf1fe9fb233491d1e8197f52293a7018a2f9925f1e34644ad1e30b134d59f
@@ -1,4 +1,14 @@
1
- ## Rails 6.1.0.rc2 (December 01, 2020) ##
1
+ ## Rails 6.1.0 (December 09, 2020) ##
2
+
3
+ * Only warn about negative enums if a positive form that would cause conflicts exists.
4
+
5
+ Fixes #39065.
6
+
7
+ *Alex Ghiculescu*
8
+
9
+ * Change `attribute_for_inspect` to take `filter_attributes` in consideration.
10
+
11
+ *Rafael Mendonça França*
2
12
 
3
13
  * Fix odd behavior of inverse_of with multiple belongs_to to same class.
4
14
 
@@ -22,9 +32,6 @@
22
32
 
23
33
  *Sean Doyle*
24
34
 
25
-
26
- ## Rails 6.1.0.rc1 (November 02, 2020) ##
27
-
28
35
  * Add `connected_to_many` API.
29
36
 
30
37
  This API allows applications to connect to multiple databases at once without switching all of them or implementing a deeply nested stack.
@@ -211,11 +211,11 @@ module ActiveRecord
211
211
 
212
212
  private
213
213
  def find_target
214
- if owner.strict_loading?
214
+ if owner.strict_loading? && owner.validation_context.nil?
215
215
  Base.strict_loading_violation!(owner: owner.class, association: klass)
216
216
  end
217
217
 
218
- if reflection.strict_loading?
218
+ if reflection.strict_loading? && owner.validation_context.nil?
219
219
  Base.strict_loading_violation!(owner: owner.class, association: reflection.name)
220
220
  end
221
221
 
@@ -84,7 +84,7 @@ module ActiveRecord
84
84
  @references = {}
85
85
 
86
86
  references.each do |table_name|
87
- @references[table_name.to_sym] = table_name if table_name.is_a?(String)
87
+ @references[table_name.to_sym] = table_name if table_name.is_a?(Arel::Nodes::SqlLiteral)
88
88
  end unless references.empty?
89
89
 
90
90
  joins = make_join_constraints(join_root, join_type)
@@ -285,7 +285,7 @@ module ActiveRecord
285
285
  attr_name = attr_name.to_s
286
286
  attr_name = self.class.attribute_aliases[attr_name] || attr_name
287
287
  value = _read_attribute(attr_name)
288
- format_for_inspect(value)
288
+ format_for_inspect(attr_name, value)
289
289
  end
290
290
 
291
291
  # Returns +true+ if the specified +attribute+ has been set by the user or by a
@@ -407,13 +407,19 @@ module ActiveRecord
407
407
  end
408
408
  end
409
409
 
410
- def format_for_inspect(value)
411
- if value.is_a?(String) && value.length > 50
412
- "#{value[0, 50]}...".inspect
413
- elsif value.is_a?(Date) || value.is_a?(Time)
414
- %("#{value.to_s(:inspect)}")
415
- else
410
+ def format_for_inspect(name, value)
411
+ if value.nil?
416
412
  value.inspect
413
+ else
414
+ inspected_value = if value.is_a?(String) && value.length > 50
415
+ "#{value[0, 50]}...".inspect
416
+ elsif value.is_a?(Date) || value.is_a?(Time)
417
+ %("#{value.to_s(:inspect)}")
418
+ else
419
+ value.inspect
420
+ end
421
+
422
+ inspection_filter.filter_param(name, inspected_value)
417
423
  end
418
424
  end
419
425
 
@@ -16,6 +16,14 @@ module ActiveRecord
16
16
  super
17
17
  end
18
18
  end
19
+
20
+ def type_cast_for_schema(value)
21
+ case value
22
+ when ::Float::INFINITY then "::Float::INFINITY"
23
+ when -::Float::INFINITY then "-::Float::INFINITY"
24
+ else super
25
+ end
26
+ end
19
27
  end
20
28
  end
21
29
  end
@@ -672,14 +672,7 @@ module ActiveRecord
672
672
  inspection = if defined?(@attributes) && @attributes
673
673
  self.class.attribute_names.collect do |name|
674
674
  if _has_attribute?(name)
675
- attr = _read_attribute(name)
676
- value = if attr.nil?
677
- attr.inspect
678
- else
679
- attr = format_for_inspect(attr)
680
- inspection_filter.filter_param(name, attr)
681
- end
682
- "#{name}: #{value}"
675
+ "#{name}: #{attribute_for_inspect(name)}"
683
676
  end
684
677
  end.compact.join(", ")
685
678
  else
@@ -189,6 +189,7 @@ module ActiveRecord
189
189
 
190
190
  _enum_methods_module.module_eval do
191
191
  pairs = values.respond_to?(:each_pair) ? values.each_pair : values.each_with_index
192
+ value_method_names = []
192
193
  pairs.each do |label, value|
193
194
  if enum_prefix == true
194
195
  prefix = "#{name}_"
@@ -203,6 +204,7 @@ module ActiveRecord
203
204
 
204
205
  method_friendly_label = label.to_s.gsub(/\W+/, "_")
205
206
  value_method_name = "#{prefix}#{method_friendly_label}#{suffix}"
207
+ value_method_names << value_method_name
206
208
  enum_values[label] = value
207
209
  label = label.to_s
208
210
 
@@ -217,8 +219,6 @@ module ActiveRecord
217
219
  # scope :active, -> { where(status: 0) }
218
220
  # scope :not_active, -> { where.not(status: 0) }
219
221
  if enum_scopes != false
220
- klass.send(:detect_negative_condition!, value_method_name)
221
-
222
222
  klass.send(:detect_enum_conflict!, name, value_method_name, true)
223
223
  klass.scope value_method_name, -> { where(attr => value) }
224
224
 
@@ -226,6 +226,7 @@ module ActiveRecord
226
226
  klass.scope "not_#{value_method_name}", -> { where.not(attr => value) }
227
227
  end
228
228
  end
229
+ klass.send(:detect_negative_enum_conditions!, value_method_names) if enum_scopes != false
229
230
  end
230
231
  enum_values.freeze
231
232
  end
@@ -281,10 +282,16 @@ module ActiveRecord
281
282
  }
282
283
  end
283
284
 
284
- def detect_negative_condition!(method_name)
285
- if method_name.start_with?("not_") && logger
286
- logger.warn "An enum element in #{self.name} uses the prefix 'not_'." \
287
- " This will cause a conflict with auto generated negative scopes."
285
+ def detect_negative_enum_conditions!(method_names)
286
+ return unless logger
287
+
288
+ method_names.select { |m| m.start_with?("not_") }.each do |potential_not|
289
+ inverted_form = potential_not.sub("not_", "")
290
+ if method_names.include?(inverted_form)
291
+ logger.warn "Enum element '#{potential_not}' in #{self.name} uses the prefix 'not_'." \
292
+ " This has caused a conflict with auto generated negative scopes." \
293
+ " Avoid using enum elements starting with 'not' where the positive form is also an element."
294
+ end
288
295
  end
289
296
  end
290
297
  end
@@ -10,7 +10,7 @@ module ActiveRecord
10
10
  MAJOR = 6
11
11
  MINOR = 1
12
12
  TINY = 0
13
- PRE = "rc2"
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -31,7 +31,7 @@ module ActiveRecord
31
31
  config.active_record.maintain_test_schema = true
32
32
  config.active_record.has_many_inversing = false
33
33
 
34
- config.active_record.queues = ActiveSupport::InheritableOptions.new(destroy: :active_record_destroy)
34
+ config.active_record.queues = ActiveSupport::InheritableOptions.new
35
35
 
36
36
  config.eager_load_namespaces << ActiveRecord
37
37
 
@@ -32,9 +32,9 @@ module ActiveRecord
32
32
  def self.references(attributes)
33
33
  attributes.each_with_object([]) do |(key, value), result|
34
34
  if value.is_a?(Hash)
35
- result << key
35
+ result << Arel.sql(key)
36
36
  elsif key.include?(".")
37
- result << key.split(".").first
37
+ result << Arel.sql(key.split(".").first)
38
38
  end
39
39
  end
40
40
  end
@@ -1505,7 +1505,7 @@ module ActiveRecord
1505
1505
  v1 = v1.uniq
1506
1506
  v2 = v2.uniq
1507
1507
  end
1508
- v1 == v2 || (!v1 || v1.empty?) && (!v2 || v2.empty?)
1508
+ v1 == v2
1509
1509
  end
1510
1510
  end
1511
1511
  end
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.0.rc2
4
+ version: 6.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: 2020-12-01 00:00:00.000000000 Z
11
+ date: 2020-12-09 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.0.rc2
19
+ version: 6.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: 6.1.0.rc2
26
+ version: 6.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: 6.1.0.rc2
33
+ version: 6.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: 6.1.0.rc2
40
+ version: 6.1.0
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,10 +390,10 @@ 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.0.rc2/activerecord/CHANGELOG.md
394
- documentation_uri: https://api.rubyonrails.org/v6.1.0.rc2/
393
+ changelog_uri: https://github.com/rails/rails/blob/v6.1.0/activerecord/CHANGELOG.md
394
+ documentation_uri: https://api.rubyonrails.org/v6.1.0/
395
395
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
396
- source_code_uri: https://github.com/rails/rails/tree/v6.1.0.rc2/activerecord
396
+ source_code_uri: https://github.com/rails/rails/tree/v6.1.0/activerecord
397
397
  post_install_message:
398
398
  rdoc_options:
399
399
  - "--main"
@@ -407,9 +407,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
407
407
  version: 2.5.0
408
408
  required_rubygems_version: !ruby/object:Gem::Requirement
409
409
  requirements:
410
- - - ">"
410
+ - - ">="
411
411
  - !ruby/object:Gem::Version
412
- version: 1.3.1
412
+ version: '0'
413
413
  requirements: []
414
414
  rubygems_version: 3.1.4
415
415
  signing_key: