activerecord 5.2.0 → 5.2.8.1
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 +4 -4
- data/CHANGELOG.md +361 -0
- data/lib/active_record/association_relation.rb +3 -3
- data/lib/active_record/associations/alias_tracker.rb +1 -1
- data/lib/active_record/associations/association.rb +25 -10
- data/lib/active_record/associations/belongs_to_association.rb +14 -5
- data/lib/active_record/associations/belongs_to_polymorphic_association.rb +4 -1
- data/lib/active_record/associations/builder/belongs_to.rb +11 -2
- data/lib/active_record/associations/builder/collection_association.rb +2 -2
- data/lib/active_record/associations/collection_association.rb +19 -15
- data/lib/active_record/associations/collection_proxy.rb +8 -34
- data/lib/active_record/associations/has_many_association.rb +9 -0
- data/lib/active_record/associations/has_many_through_association.rb +29 -12
- data/lib/active_record/associations/has_one_association.rb +8 -0
- data/lib/active_record/associations/has_one_through_association.rb +5 -1
- data/lib/active_record/associations/join_dependency/join_association.rb +39 -24
- data/lib/active_record/associations/join_dependency/join_part.rb +7 -0
- data/lib/active_record/associations/join_dependency.rb +39 -64
- data/lib/active_record/associations/preloader.rb +1 -1
- data/lib/active_record/associations/singular_association.rb +4 -10
- data/lib/active_record/associations/through_association.rb +1 -1
- data/lib/active_record/associations.rb +9 -9
- data/lib/active_record/attribute_methods/dirty.rb +15 -10
- data/lib/active_record/attribute_methods/read.rb +1 -1
- data/lib/active_record/autosave_association.rb +27 -8
- data/lib/active_record/callbacks.rb +4 -0
- data/lib/active_record/coders/yaml_column.rb +13 -1
- data/lib/active_record/collection_cache_key.rb +2 -2
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +36 -11
- data/lib/active_record/connection_adapters/abstract/database_limits.rb +5 -0
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +19 -6
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +8 -3
- data/lib/active_record/connection_adapters/abstract/quoting.rb +1 -0
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +7 -4
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +6 -15
- data/lib/active_record/connection_adapters/abstract/transaction.rb +23 -14
- data/lib/active_record/connection_adapters/abstract_adapter.rb +3 -1
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +18 -19
- data/lib/active_record/connection_adapters/connection_specification.rb +2 -2
- data/lib/active_record/connection_adapters/determine_if_preparable_visitor.rb +11 -2
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +36 -0
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +11 -1
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +2 -2
- data/lib/active_record/connection_adapters/postgresql/oid/range.rb +4 -0
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +36 -0
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +12 -26
- data/lib/active_record/connection_adapters/postgresql/utils.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +9 -1
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +5 -0
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +5 -1
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +3 -6
- data/lib/active_record/core.rb +12 -1
- data/lib/active_record/counter_cache.rb +17 -13
- data/lib/active_record/enum.rb +1 -0
- data/lib/active_record/errors.rb +18 -12
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/log_subscriber.rb +1 -1
- data/lib/active_record/migration/compatibility.rb +15 -15
- data/lib/active_record/migration.rb +1 -1
- data/lib/active_record/model_schema.rb +1 -1
- data/lib/active_record/persistence.rb +6 -5
- data/lib/active_record/query_cache.rb +4 -11
- data/lib/active_record/querying.rb +1 -1
- data/lib/active_record/railtie.rb +19 -3
- data/lib/active_record/reflection.rb +10 -14
- data/lib/active_record/relation/calculations.rb +16 -12
- data/lib/active_record/relation/delegation.rb +30 -0
- data/lib/active_record/relation/finder_methods.rb +10 -8
- data/lib/active_record/relation/merger.rb +10 -11
- data/lib/active_record/relation/predicate_builder/array_handler.rb +2 -2
- data/lib/active_record/relation/predicate_builder.rb +20 -14
- data/lib/active_record/relation/query_attribute.rb +5 -3
- data/lib/active_record/relation/query_methods.rb +50 -22
- data/lib/active_record/relation/spawn_methods.rb +1 -1
- data/lib/active_record/relation.rb +39 -20
- data/lib/active_record/scoping/default.rb +2 -2
- data/lib/active_record/scoping/named.rb +2 -0
- data/lib/active_record/statement_cache.rb +2 -2
- data/lib/active_record/tasks/database_tasks.rb +1 -1
- data/lib/active_record/timestamp.rb +8 -1
- data/lib/active_record/transactions.rb +24 -21
- data/lib/active_record/type/serialized.rb +4 -0
- metadata +12 -13
@@ -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
|
125
|
+
$stderr.puts "Couldn't create '#{configuration['database']}' database. Please check your configuration."
|
126
126
|
raise
|
127
127
|
end
|
128
128
|
|
@@ -52,7 +52,14 @@ module ActiveRecord
|
|
52
52
|
clear_timestamp_attributes
|
53
53
|
end
|
54
54
|
|
55
|
-
|
55
|
+
module ClassMethods # :nodoc:
|
56
|
+
def touch_attributes_with_time(*names, time: nil)
|
57
|
+
attribute_names = timestamp_attributes_for_update_in_model
|
58
|
+
attribute_names |= names.map(&:to_s)
|
59
|
+
time ||= current_time_from_proper_timezone
|
60
|
+
attribute_names.each_with_object({}) { |attr_name, result| result[attr_name] = time }
|
61
|
+
end
|
62
|
+
|
56
63
|
private
|
57
64
|
def timestamp_attributes_for_create_in_model
|
58
65
|
timestamp_attributes_for_create.select { |c| column_names.include?(c) }
|
@@ -340,12 +340,14 @@ 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
|
-
|
343
|
+
force_clear_transaction_record_state
|
344
|
+
if should_run_callbacks && (destroyed? || persisted?)
|
345
|
+
@_committed_already_called = true
|
344
346
|
_run_commit_without_transaction_enrollment_callbacks
|
345
347
|
_run_commit_callbacks
|
346
348
|
end
|
347
349
|
ensure
|
348
|
-
|
350
|
+
@_committed_already_called = false
|
349
351
|
end
|
350
352
|
|
351
353
|
# Call the #after_rollback callbacks. The +force_restore_state+ argument indicates if the record
|
@@ -382,13 +384,7 @@ module ActiveRecord
|
|
382
384
|
status = nil
|
383
385
|
self.class.transaction do
|
384
386
|
add_to_transaction
|
385
|
-
|
386
|
-
status = yield
|
387
|
-
rescue ActiveRecord::Rollback
|
388
|
-
clear_transaction_record_state
|
389
|
-
status = nil
|
390
|
-
end
|
391
|
-
|
387
|
+
status = yield
|
392
388
|
raise ActiveRecord::Rollback unless status
|
393
389
|
end
|
394
390
|
status
|
@@ -398,17 +394,29 @@ module ActiveRecord
|
|
398
394
|
end
|
399
395
|
end
|
400
396
|
|
397
|
+
protected
|
398
|
+
attr_reader :_committed_already_called, :_trigger_update_callback, :_trigger_destroy_callback
|
399
|
+
|
401
400
|
private
|
402
401
|
|
403
402
|
# Save the new record state and id of a record so it can be restored later if a transaction fails.
|
404
403
|
def remember_transaction_record_state
|
405
|
-
@_start_transaction_state[:id] = id
|
406
404
|
@_start_transaction_state.reverse_merge!(
|
405
|
+
id: id,
|
407
406
|
new_record: @new_record,
|
408
407
|
destroyed: @destroyed,
|
409
408
|
frozen?: frozen?,
|
410
409
|
)
|
411
410
|
@_start_transaction_state[:level] = (@_start_transaction_state[:level] || 0) + 1
|
411
|
+
remember_new_record_before_last_commit
|
412
|
+
end
|
413
|
+
|
414
|
+
def remember_new_record_before_last_commit
|
415
|
+
if _committed_already_called
|
416
|
+
@_new_record_before_last_commit = false
|
417
|
+
else
|
418
|
+
@_new_record_before_last_commit = @_start_transaction_state[:new_record]
|
419
|
+
end
|
412
420
|
end
|
413
421
|
|
414
422
|
# Clear the new record state and id of a record.
|
@@ -440,22 +448,16 @@ module ActiveRecord
|
|
440
448
|
end
|
441
449
|
end
|
442
450
|
|
443
|
-
# Determine if a record was created or destroyed in a transaction. State should be one of :new_record or :destroyed.
|
444
|
-
def transaction_record_state(state)
|
445
|
-
@_start_transaction_state[state]
|
446
|
-
end
|
447
|
-
|
448
451
|
# Determine if a transaction included an action for :create, :update, or :destroy. Used in filtering callbacks.
|
449
452
|
def transaction_include_any_action?(actions)
|
450
453
|
actions.any? do |action|
|
451
454
|
case action
|
452
455
|
when :create
|
453
|
-
|
454
|
-
when :destroy
|
455
|
-
defined?(@_trigger_destroy_callback) && @_trigger_destroy_callback
|
456
|
+
persisted? && @_new_record_before_last_commit
|
456
457
|
when :update
|
457
|
-
!(
|
458
|
-
|
458
|
+
!(@_new_record_before_last_commit || destroyed?) && _trigger_update_callback
|
459
|
+
when :destroy
|
460
|
+
_trigger_destroy_callback
|
459
461
|
end
|
460
462
|
end
|
461
463
|
end
|
@@ -491,7 +493,8 @@ module ActiveRecord
|
|
491
493
|
|
492
494
|
def update_attributes_from_transaction_state(transaction_state)
|
493
495
|
if transaction_state && transaction_state.finalized?
|
494
|
-
restore_transaction_record_state if transaction_state.rolledback?
|
496
|
+
restore_transaction_record_state(transaction_state.fully_rolledback?) if transaction_state.rolledback?
|
497
|
+
force_clear_transaction_record_state if transaction_state.fully_committed?
|
495
498
|
clear_transaction_record_state if transaction_state.fully_completed?
|
496
499
|
end
|
497
500
|
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: 5.2.
|
4
|
+
version: 5.2.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-07-12 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.
|
19
|
+
version: 5.2.8.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: 5.2.
|
26
|
+
version: 5.2.8.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: 5.2.
|
33
|
+
version: 5.2.8.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: 5.2.
|
40
|
+
version: 5.2.8.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: arel
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -307,9 +307,9 @@ 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.
|
311
|
-
changelog_uri: https://github.com/rails/rails/blob/v5.2.
|
312
|
-
post_install_message:
|
310
|
+
source_code_uri: https://github.com/rails/rails/tree/v5.2.8.1/activerecord
|
311
|
+
changelog_uri: https://github.com/rails/rails/blob/v5.2.8.1/activerecord/CHANGELOG.md
|
312
|
+
post_install_message:
|
313
313
|
rdoc_options:
|
314
314
|
- "--main"
|
315
315
|
- README.rdoc
|
@@ -326,9 +326,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
326
326
|
- !ruby/object:Gem::Version
|
327
327
|
version: '0'
|
328
328
|
requirements: []
|
329
|
-
|
330
|
-
|
331
|
-
signing_key:
|
329
|
+
rubygems_version: 3.3.3
|
330
|
+
signing_key:
|
332
331
|
specification_version: 4
|
333
332
|
summary: Object-relational mapper framework (part of Rails).
|
334
333
|
test_files: []
|