activerecord 5.2.1 → 5.2.5

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 (59) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +228 -0
  3. data/lib/active_record/association_relation.rb +3 -3
  4. data/lib/active_record/associations/association.rb +8 -0
  5. data/lib/active_record/associations/builder/collection_association.rb +2 -2
  6. data/lib/active_record/associations/collection_association.rb +9 -8
  7. data/lib/active_record/associations/collection_proxy.rb +8 -34
  8. data/lib/active_record/associations/has_many_association.rb +9 -0
  9. data/lib/active_record/associations/has_many_through_association.rb +28 -11
  10. data/lib/active_record/associations/join_dependency/join_association.rb +28 -7
  11. data/lib/active_record/associations/preloader.rb +1 -1
  12. data/lib/active_record/attribute_methods/dirty.rb +13 -8
  13. data/lib/active_record/autosave_association.rb +25 -11
  14. data/lib/active_record/callbacks.rb +1 -1
  15. data/lib/active_record/collection_cache_key.rb +2 -2
  16. data/lib/active_record/connection_adapters/abstract/connection_pool.rb +36 -11
  17. data/lib/active_record/connection_adapters/abstract/database_limits.rb +5 -0
  18. data/lib/active_record/connection_adapters/abstract/database_statements.rb +19 -6
  19. data/lib/active_record/connection_adapters/abstract/query_cache.rb +8 -3
  20. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +3 -3
  21. data/lib/active_record/connection_adapters/abstract_adapter.rb +3 -1
  22. data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +18 -8
  23. data/lib/active_record/connection_adapters/connection_specification.rb +2 -2
  24. data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +11 -2
  25. data/lib/active_record/connection_adapters/postgresql/oid/array.rb +7 -1
  26. data/lib/active_record/connection_adapters/postgresql/oid/money.rb +2 -2
  27. data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +36 -0
  28. data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +10 -24
  29. data/lib/active_record/connection_adapters/postgresql/utils.rb +1 -1
  30. data/lib/active_record/connection_adapters/postgresql_adapter.rb +9 -1
  31. data/lib/active_record/connection_adapters/sqlite3/quoting.rb +4 -0
  32. data/lib/active_record/connection_adapters/sqlite3_adapter.rb +3 -3
  33. data/lib/active_record/core.rb +2 -1
  34. data/lib/active_record/enum.rb +1 -0
  35. data/lib/active_record/errors.rb +18 -12
  36. data/lib/active_record/gem_version.rb +1 -1
  37. data/lib/active_record/migration.rb +1 -1
  38. data/lib/active_record/migration/compatibility.rb +15 -15
  39. data/lib/active_record/model_schema.rb +1 -1
  40. data/lib/active_record/persistence.rb +5 -4
  41. data/lib/active_record/querying.rb +1 -1
  42. data/lib/active_record/railtie.rb +1 -3
  43. data/lib/active_record/reflection.rb +10 -14
  44. data/lib/active_record/relation.rb +26 -7
  45. data/lib/active_record/relation/calculations.rb +16 -12
  46. data/lib/active_record/relation/delegation.rb +30 -0
  47. data/lib/active_record/relation/finder_methods.rb +8 -4
  48. data/lib/active_record/relation/merger.rb +8 -5
  49. data/lib/active_record/relation/predicate_builder.rb +14 -9
  50. data/lib/active_record/relation/predicate_builder/array_handler.rb +2 -2
  51. data/lib/active_record/relation/query_attribute.rb +5 -3
  52. data/lib/active_record/relation/query_methods.rb +35 -10
  53. data/lib/active_record/relation/spawn_methods.rb +1 -1
  54. data/lib/active_record/scoping/default.rb +2 -2
  55. data/lib/active_record/scoping/named.rb +2 -0
  56. data/lib/active_record/statement_cache.rb +2 -2
  57. data/lib/active_record/tasks/database_tasks.rb +1 -1
  58. data/lib/active_record/transactions.rb +1 -1
  59. metadata +9 -10
@@ -8,7 +8,7 @@ module ActiveRecord
8
8
  module SpawnMethods
9
9
  # This is overridden by Associations::CollectionProxy
10
10
  def spawn #:nodoc:
11
- clone
11
+ @delegate_to_klass ? klass.all : clone
12
12
  end
13
13
 
14
14
  # Merges in the conditions from <tt>other</tt>, if <tt>other</tt> is an ActiveRecord::Relation.
@@ -86,8 +86,8 @@ module ActiveRecord
86
86
  # # Should return a scope, you can call 'super' here etc.
87
87
  # end
88
88
  # end
89
- def default_scope(scope = nil) # :doc:
90
- scope = Proc.new if block_given?
89
+ def default_scope(scope = nil, &block) # :doc:
90
+ scope = block if block_given?
91
91
 
92
92
  if scope.is_a?(Relation) || !scope.respond_to?(:call)
93
93
  raise ArgumentError,
@@ -195,6 +195,8 @@ module ActiveRecord
195
195
  scope
196
196
  end
197
197
  end
198
+
199
+ generate_relation_method(name)
198
200
  end
199
201
 
200
202
  private
@@ -87,8 +87,8 @@ module ActiveRecord
87
87
  end
88
88
  end
89
89
 
90
- def self.create(connection, block = Proc.new)
91
- relation = block.call Params.new
90
+ def self.create(connection, callable = nil, &block)
91
+ relation = (callable || block).call Params.new
92
92
  query_builder, binds = connection.cacheable_query(self, relation.arel)
93
93
  bind_map = BindMap.new(binds)
94
94
  new(query_builder, bind_map, relation.klass)
@@ -122,7 +122,7 @@ module ActiveRecord
122
122
  $stderr.puts "Database '#{configuration['database']}' already exists"
123
123
  rescue Exception => error
124
124
  $stderr.puts error
125
- $stderr.puts "Couldn't create database for #{configuration.inspect}"
125
+ $stderr.puts "Couldn't create '#{configuration['database']}' database. Please check your configuration."
126
126
  raise
127
127
  end
128
128
 
@@ -340,6 +340,7 @@ module ActiveRecord
340
340
  # Ensure that it is not called if the object was never persisted (failed create),
341
341
  # but call it after the commit of a destroyed object.
342
342
  def committed!(should_run_callbacks: true) #:nodoc:
343
+ force_clear_transaction_record_state
343
344
  if should_run_callbacks && (destroyed? || persisted?)
344
345
  @_committed_already_called = true
345
346
  _run_commit_without_transaction_enrollment_callbacks
@@ -347,7 +348,6 @@ module ActiveRecord
347
348
  end
348
349
  ensure
349
350
  @_committed_already_called = false
350
- force_clear_transaction_record_state
351
351
  end
352
352
 
353
353
  # Call the #after_rollback callbacks. The +force_restore_state+ argument indicates if the record
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: 5.2.1
4
+ version: 5.2.5
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: 2018-08-07 00:00:00.000000000 Z
11
+ date: 2021-03-26 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: 5.2.1
19
+ version: 5.2.5
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: 5.2.1
26
+ version: 5.2.5
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: 5.2.1
33
+ version: 5.2.5
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: 5.2.1
40
+ version: 5.2.5
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: arel
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -307,8 +307,8 @@ homepage: http://rubyonrails.org
307
307
  licenses:
308
308
  - MIT
309
309
  metadata:
310
- source_code_uri: https://github.com/rails/rails/tree/v5.2.1/activerecord
311
- changelog_uri: https://github.com/rails/rails/blob/v5.2.1/activerecord/CHANGELOG.md
310
+ source_code_uri: https://github.com/rails/rails/tree/v5.2.5/activerecord
311
+ changelog_uri: https://github.com/rails/rails/blob/v5.2.5/activerecord/CHANGELOG.md
312
312
  post_install_message:
313
313
  rdoc_options:
314
314
  - "--main"
@@ -326,8 +326,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
326
326
  - !ruby/object:Gem::Version
327
327
  version: '0'
328
328
  requirements: []
329
- rubyforge_project:
330
- rubygems_version: 2.7.6
329
+ rubygems_version: 3.1.2
331
330
  signing_key:
332
331
  specification_version: 4
333
332
  summary: Object-relational mapper framework (part of Rails).