activerecord 7.1.0 → 7.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +194 -0
- data/README.rdoc +1 -0
- data/lib/active_record/associations/association.rb +2 -1
- data/lib/active_record/associations/preloader/association.rb +4 -1
- data/lib/active_record/associations.rb +15 -15
- data/lib/active_record/attribute_methods/before_type_cast.rb +1 -1
- data/lib/active_record/attribute_methods/dirty.rb +14 -10
- data/lib/active_record/attribute_methods.rb +1 -1
- data/lib/active_record/callbacks.rb +2 -2
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +11 -8
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +5 -3
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +2 -1
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +1 -3
- data/lib/active_record/connection_adapters/abstract_adapter.rb +13 -4
- data/lib/active_record/connection_adapters/mysql2/database_statements.rb +3 -0
- data/lib/active_record/connection_adapters/postgresql/column.rb +14 -2
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +4 -1
- data/lib/active_record/connection_adapters/postgresql/oid/money.rb +3 -2
- data/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +14 -6
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +32 -32
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +10 -3
- data/lib/active_record/connection_adapters/trilogy/database_statements.rb +1 -0
- data/lib/active_record/connection_adapters/trilogy_adapter.rb +9 -1
- data/lib/active_record/connection_handling.rb +1 -1
- data/lib/active_record/core.rb +62 -28
- data/lib/active_record/delegated_type.rb +1 -1
- data/lib/active_record/encryption/encryptable_record.rb +7 -1
- data/lib/active_record/encryption/encrypted_attribute_type.rb +4 -0
- data/lib/active_record/encryption/extended_deterministic_queries.rb +0 -15
- data/lib/active_record/enum.rb +6 -9
- data/lib/active_record/errors.rb +5 -4
- data/lib/active_record/fixtures.rb +16 -0
- data/lib/active_record/future_result.rb +1 -0
- data/lib/active_record/gem_version.rb +1 -1
- data/lib/active_record/insert_all.rb +3 -3
- data/lib/active_record/internal_metadata.rb +3 -1
- data/lib/active_record/middleware/database_selector.rb +1 -1
- data/lib/active_record/migration/command_recorder.rb +4 -1
- data/lib/active_record/migration/compatibility.rb +8 -0
- data/lib/active_record/migration/pending_migration_connection.rb +21 -0
- data/lib/active_record/migration.rb +9 -5
- data/lib/active_record/model_schema.rb +5 -5
- data/lib/active_record/nested_attributes.rb +7 -9
- data/lib/active_record/normalization.rb +8 -0
- data/lib/active_record/persistence.rb +4 -3
- data/lib/active_record/promise.rb +1 -1
- data/lib/active_record/railtie.rb +1 -1
- data/lib/active_record/railties/controller_runtime.rb +2 -1
- data/lib/active_record/railties/databases.rake +5 -5
- data/lib/active_record/reflection.rb +13 -1
- data/lib/active_record/relation/calculations.rb +44 -9
- data/lib/active_record/relation/delegation.rb +1 -1
- data/lib/active_record/relation/query_methods.rb +1 -1
- data/lib/active_record/relation.rb +18 -3
- data/lib/active_record/runtime_registry.rb +15 -1
- data/lib/active_record/schema_migration.rb +1 -1
- data/lib/active_record/secure_token.rb +1 -1
- data/lib/active_record/tasks/database_tasks.rb +5 -5
- data/lib/active_record/timestamp.rb +1 -1
- data/lib/arel/nodes/homogeneous_in.rb +1 -1
- metadata +10 -9
@@ -164,8 +164,8 @@ module ActiveRecord
|
|
164
164
|
#
|
165
165
|
# If creation failed because of a unique constraint, this method will
|
166
166
|
# assume it encountered a race condition and will try finding the record
|
167
|
-
# once more If somehow the second find still find
|
168
|
-
# concurrent DELETE happened, it will then raise an
|
167
|
+
# once more. If somehow the second find still does not find a record
|
168
|
+
# because a concurrent DELETE happened, it will then raise an
|
169
169
|
# ActiveRecord::RecordNotFound exception.
|
170
170
|
#
|
171
171
|
# Please note <b>this method is not atomic</b>, it runs first a SELECT,
|
@@ -291,6 +291,11 @@ module ActiveRecord
|
|
291
291
|
end
|
292
292
|
|
293
293
|
# Returns true if there are no records.
|
294
|
+
#
|
295
|
+
# When a pattern argument is given, this method checks whether elements in
|
296
|
+
# the Enumerable match the pattern via the case-equality operator (<tt>===</tt>).
|
297
|
+
#
|
298
|
+
# posts.none?(Comment) # => true or false
|
294
299
|
def none?(*args)
|
295
300
|
return true if @none
|
296
301
|
|
@@ -299,6 +304,11 @@ module ActiveRecord
|
|
299
304
|
end
|
300
305
|
|
301
306
|
# Returns true if there are any records.
|
307
|
+
#
|
308
|
+
# When a pattern argument is given, this method checks whether elements in
|
309
|
+
# the Enumerable match the pattern via the case-equality operator (<tt>===</tt>).
|
310
|
+
#
|
311
|
+
# posts.any?(Post) # => true or false
|
302
312
|
def any?(*args)
|
303
313
|
return false if @none
|
304
314
|
|
@@ -307,6 +317,11 @@ module ActiveRecord
|
|
307
317
|
end
|
308
318
|
|
309
319
|
# Returns true if there is exactly one record.
|
320
|
+
#
|
321
|
+
# When a pattern argument is given, this method checks whether elements in
|
322
|
+
# the Enumerable match the pattern via the case-equality operator (<tt>===</tt>).
|
323
|
+
#
|
324
|
+
# posts.one?(Post) # => true or false
|
310
325
|
def one?(*args)
|
311
326
|
return false if @none
|
312
327
|
|
@@ -960,7 +975,7 @@ module ActiveRecord
|
|
960
975
|
def exec_main_query(async: false)
|
961
976
|
if @none
|
962
977
|
if async
|
963
|
-
return
|
978
|
+
return FutureResult::Complete.new([])
|
964
979
|
else
|
965
980
|
return []
|
966
981
|
end
|
@@ -17,13 +17,27 @@ module ActiveRecord
|
|
17
17
|
ActiveSupport::IsolatedExecutionState[:active_record_sql_runtime] = runtime
|
18
18
|
end
|
19
19
|
|
20
|
+
def async_sql_runtime
|
21
|
+
ActiveSupport::IsolatedExecutionState[:active_record_async_sql_runtime] ||= 0.0
|
22
|
+
end
|
23
|
+
|
24
|
+
def async_sql_runtime=(runtime)
|
25
|
+
ActiveSupport::IsolatedExecutionState[:active_record_async_sql_runtime] = runtime
|
26
|
+
end
|
27
|
+
|
20
28
|
def reset
|
21
29
|
rt, self.sql_runtime = sql_runtime, 0.0
|
30
|
+
self.async_sql_runtime = 0.0
|
22
31
|
rt
|
23
32
|
end
|
24
33
|
end
|
25
34
|
end
|
26
35
|
|
27
36
|
ActiveSupport::Notifications.monotonic_subscribe("sql.active_record") do |name, start, finish, id, payload|
|
28
|
-
|
37
|
+
runtime = (finish - start) * 1_000.0
|
38
|
+
|
39
|
+
if payload[:async]
|
40
|
+
ActiveRecord::RuntimeRegistry.async_sql_runtime += (runtime - payload[:lock_wait])
|
41
|
+
end
|
42
|
+
ActiveRecord::RuntimeRegistry.sql_runtime += runtime
|
29
43
|
end
|
@@ -6,7 +6,7 @@ module ActiveRecord
|
|
6
6
|
# number is inserted in to the schema migrations table so it doesn't need
|
7
7
|
# to be executed the next time.
|
8
8
|
class SchemaMigration # :nodoc:
|
9
|
-
class NullSchemaMigration
|
9
|
+
class NullSchemaMigration # :nodoc:
|
10
10
|
end
|
11
11
|
|
12
12
|
attr_reader :connection, :arel_table
|
@@ -53,7 +53,7 @@ module ActiveRecord
|
|
53
53
|
define_method("regenerate_#{attribute}") { update! attribute => self.class.generate_unique_secure_token(length: length) }
|
54
54
|
set_callback on, on == :initialize ? :after : :before do
|
55
55
|
if new_record? && !query_attribute(attribute)
|
56
|
-
|
56
|
+
send("#{attribute}=", self.class.generate_unique_secure_token(length: length))
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -125,11 +125,11 @@ module ActiveRecord
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def create_all
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
128
|
+
each_local_configuration do |db_config|
|
129
|
+
with_temporary_connection(db_config) do
|
130
|
+
create(db_config)
|
131
|
+
end
|
132
|
+
end
|
133
133
|
end
|
134
134
|
|
135
135
|
def setup_initial_database_yaml # :nodoc:
|
@@ -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
|
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
|
#
|
@@ -48,7 +48,7 @@ module Arel # :nodoc: all
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def proc_for_binds
|
51
|
-
-> value { ActiveModel::Attribute.with_cast_value(attribute.name, value,
|
51
|
+
-> value { ActiveModel::Attribute.with_cast_value(attribute.name, value, ActiveModel::Type.default_value) }
|
52
52
|
end
|
53
53
|
|
54
54
|
def fetch_attribute(&block)
|
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.
|
4
|
+
version: 7.1.3
|
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:
|
11
|
+
date: 2024-01-16 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.
|
19
|
+
version: 7.1.3
|
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.
|
26
|
+
version: 7.1.3
|
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.
|
33
|
+
version: 7.1.3
|
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.
|
40
|
+
version: 7.1.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: timeout
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -279,6 +279,7 @@ files:
|
|
279
279
|
- lib/active_record/migration/default_strategy.rb
|
280
280
|
- lib/active_record/migration/execution_strategy.rb
|
281
281
|
- lib/active_record/migration/join_table.rb
|
282
|
+
- lib/active_record/migration/pending_migration_connection.rb
|
282
283
|
- lib/active_record/model_schema.rb
|
283
284
|
- lib/active_record/nested_attributes.rb
|
284
285
|
- lib/active_record/no_touching.rb
|
@@ -469,10 +470,10 @@ licenses:
|
|
469
470
|
- MIT
|
470
471
|
metadata:
|
471
472
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
472
|
-
changelog_uri: https://github.com/rails/rails/blob/v7.1.
|
473
|
-
documentation_uri: https://api.rubyonrails.org/v7.1.
|
473
|
+
changelog_uri: https://github.com/rails/rails/blob/v7.1.3/activerecord/CHANGELOG.md
|
474
|
+
documentation_uri: https://api.rubyonrails.org/v7.1.3/
|
474
475
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
475
|
-
source_code_uri: https://github.com/rails/rails/tree/v7.1.
|
476
|
+
source_code_uri: https://github.com/rails/rails/tree/v7.1.3/activerecord
|
476
477
|
rubygems_mfa_required: 'true'
|
477
478
|
post_install_message:
|
478
479
|
rdoc_options:
|