activerecord 7.2.3 → 8.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +612 -1055
- data/README.rdoc +1 -1
- data/lib/active_record/association_relation.rb +2 -1
- data/lib/active_record/associations/association.rb +35 -11
- data/lib/active_record/associations/builder/association.rb +23 -11
- data/lib/active_record/associations/builder/belongs_to.rb +17 -4
- data/lib/active_record/associations/builder/collection_association.rb +7 -3
- data/lib/active_record/associations/builder/has_one.rb +1 -1
- data/lib/active_record/associations/builder/singular_association.rb +33 -5
- data/lib/active_record/associations/collection_association.rb +1 -1
- data/lib/active_record/associations/collection_proxy.rb +22 -4
- data/lib/active_record/associations/deprecation.rb +88 -0
- data/lib/active_record/associations/disable_joins_association_scope.rb +1 -1
- data/lib/active_record/associations/errors.rb +3 -0
- data/lib/active_record/associations/has_many_through_association.rb +3 -2
- data/lib/active_record/associations/join_dependency.rb +4 -2
- data/lib/active_record/associations/preloader/association.rb +2 -2
- data/lib/active_record/associations/preloader/batch.rb +7 -1
- data/lib/active_record/associations/preloader/branch.rb +1 -0
- data/lib/active_record/associations/singular_association.rb +8 -3
- data/lib/active_record/associations.rb +192 -24
- data/lib/active_record/asynchronous_queries_tracker.rb +28 -24
- data/lib/active_record/attribute_methods/primary_key.rb +4 -8
- data/lib/active_record/attribute_methods/query.rb +34 -0
- data/lib/active_record/attribute_methods/serialization.rb +16 -3
- data/lib/active_record/attribute_methods/time_zone_conversion.rb +12 -14
- data/lib/active_record/attributes.rb +3 -0
- data/lib/active_record/autosave_association.rb +69 -27
- data/lib/active_record/base.rb +1 -2
- data/lib/active_record/coders/json.rb +14 -5
- data/lib/active_record/connection_adapters/abstract/connection_handler.rb +35 -28
- data/lib/active_record/connection_adapters/abstract/connection_pool/queue.rb +16 -4
- data/lib/active_record/connection_adapters/abstract/connection_pool/reaper.rb +51 -13
- data/lib/active_record/connection_adapters/abstract/connection_pool.rb +412 -88
- data/lib/active_record/connection_adapters/abstract/database_statements.rb +137 -75
- data/lib/active_record/connection_adapters/abstract/query_cache.rb +27 -5
- data/lib/active_record/connection_adapters/abstract/quoting.rb +16 -25
- data/lib/active_record/connection_adapters/abstract/schema_creation.rb +11 -7
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +32 -35
- data/lib/active_record/connection_adapters/abstract/schema_dumper.rb +2 -1
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +122 -32
- data/lib/active_record/connection_adapters/abstract/transaction.rb +40 -8
- data/lib/active_record/connection_adapters/abstract_adapter.rb +150 -91
- data/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +63 -52
- data/lib/active_record/connection_adapters/column.rb +17 -4
- data/lib/active_record/connection_adapters/mysql/database_statements.rb +4 -4
- data/lib/active_record/connection_adapters/mysql/quoting.rb +0 -8
- data/lib/active_record/connection_adapters/mysql/schema_creation.rb +2 -0
- data/lib/active_record/connection_adapters/mysql/schema_definitions.rb +41 -10
- data/lib/active_record/connection_adapters/mysql/schema_statements.rb +73 -46
- data/lib/active_record/connection_adapters/mysql2/database_statements.rb +89 -94
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +2 -10
- data/lib/active_record/connection_adapters/pool_config.rb +7 -7
- data/lib/active_record/connection_adapters/postgresql/column.rb +8 -2
- data/lib/active_record/connection_adapters/postgresql/database_statements.rb +76 -45
- data/lib/active_record/connection_adapters/postgresql/oid/array.rb +3 -3
- data/lib/active_record/connection_adapters/postgresql/oid/point.rb +10 -0
- data/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql/quoting.rb +21 -10
- data/lib/active_record/connection_adapters/postgresql/referential_integrity.rb +2 -4
- data/lib/active_record/connection_adapters/postgresql/schema_creation.rb +9 -17
- data/lib/active_record/connection_adapters/postgresql/schema_definitions.rb +14 -33
- data/lib/active_record/connection_adapters/postgresql/schema_dumper.rb +71 -32
- data/lib/active_record/connection_adapters/postgresql/schema_statements.rb +139 -63
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +78 -105
- data/lib/active_record/connection_adapters/schema_cache.rb +3 -5
- data/lib/active_record/connection_adapters/sqlite3/column.rb +8 -2
- data/lib/active_record/connection_adapters/sqlite3/database_statements.rb +90 -98
- data/lib/active_record/connection_adapters/sqlite3/quoting.rb +0 -8
- data/lib/active_record/connection_adapters/sqlite3/schema_creation.rb +0 -6
- data/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb +27 -2
- data/lib/active_record/connection_adapters/sqlite3/schema_statements.rb +13 -14
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +102 -37
- data/lib/active_record/connection_adapters/statement_pool.rb +4 -2
- data/lib/active_record/connection_adapters/trilogy/database_statements.rb +38 -67
- data/lib/active_record/connection_adapters/trilogy_adapter.rb +1 -18
- data/lib/active_record/connection_adapters.rb +1 -56
- data/lib/active_record/connection_handling.rb +25 -2
- data/lib/active_record/core.rb +33 -17
- data/lib/active_record/counter_cache.rb +33 -8
- data/lib/active_record/database_configurations/database_config.rb +9 -1
- data/lib/active_record/database_configurations/hash_config.rb +67 -9
- data/lib/active_record/database_configurations/url_config.rb +13 -3
- data/lib/active_record/database_configurations.rb +7 -3
- data/lib/active_record/delegated_type.rb +1 -1
- data/lib/active_record/dynamic_matchers.rb +54 -69
- data/lib/active_record/encryption/config.rb +3 -1
- data/lib/active_record/encryption/encryptable_record.rb +8 -8
- data/lib/active_record/encryption/encrypted_attribute_type.rb +11 -2
- data/lib/active_record/encryption/encryptor.rb +28 -8
- data/lib/active_record/encryption/extended_deterministic_queries.rb +4 -2
- data/lib/active_record/encryption/scheme.rb +9 -2
- data/lib/active_record/enum.rb +33 -30
- data/lib/active_record/errors.rb +33 -9
- data/lib/active_record/explain.rb +1 -1
- data/lib/active_record/explain_registry.rb +51 -2
- data/lib/active_record/filter_attribute_handler.rb +73 -0
- data/lib/active_record/fixtures.rb +2 -4
- data/lib/active_record/future_result.rb +15 -9
- data/lib/active_record/gem_version.rb +2 -2
- data/lib/active_record/inheritance.rb +1 -1
- data/lib/active_record/insert_all.rb +14 -9
- data/lib/active_record/locking/optimistic.rb +8 -1
- data/lib/active_record/locking/pessimistic.rb +5 -0
- data/lib/active_record/log_subscriber.rb +3 -13
- data/lib/active_record/middleware/shard_selector.rb +34 -17
- data/lib/active_record/migration/command_recorder.rb +45 -12
- data/lib/active_record/migration/compatibility.rb +37 -24
- data/lib/active_record/migration/default_schema_versions_formatter.rb +30 -0
- data/lib/active_record/migration.rb +48 -42
- data/lib/active_record/model_schema.rb +38 -13
- data/lib/active_record/nested_attributes.rb +6 -6
- data/lib/active_record/persistence.rb +162 -133
- data/lib/active_record/query_cache.rb +22 -15
- data/lib/active_record/query_logs.rb +100 -52
- data/lib/active_record/query_logs_formatter.rb +17 -28
- data/lib/active_record/querying.rb +8 -8
- data/lib/active_record/railtie.rb +35 -30
- data/lib/active_record/railties/controller_runtime.rb +11 -6
- data/lib/active_record/railties/databases.rake +26 -38
- data/lib/active_record/railties/job_checkpoints.rb +15 -0
- data/lib/active_record/railties/job_runtime.rb +10 -11
- data/lib/active_record/reflection.rb +53 -21
- data/lib/active_record/relation/batches/batch_enumerator.rb +4 -3
- data/lib/active_record/relation/batches.rb +147 -73
- data/lib/active_record/relation/calculations.rb +52 -40
- data/lib/active_record/relation/delegation.rb +25 -15
- data/lib/active_record/relation/finder_methods.rb +40 -24
- data/lib/active_record/relation/merger.rb +8 -8
- data/lib/active_record/relation/predicate_builder/array_handler.rb +3 -1
- data/lib/active_record/relation/predicate_builder/association_query_value.rb +9 -9
- data/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb +8 -8
- data/lib/active_record/relation/predicate_builder/relation_handler.rb +4 -3
- data/lib/active_record/relation/predicate_builder.rb +22 -7
- data/lib/active_record/relation/query_attribute.rb +3 -1
- data/lib/active_record/relation/query_methods.rb +140 -86
- data/lib/active_record/relation/spawn_methods.rb +7 -7
- data/lib/active_record/relation/where_clause.rb +2 -9
- data/lib/active_record/relation.rb +107 -75
- data/lib/active_record/result.rb +109 -24
- data/lib/active_record/runtime_registry.rb +42 -58
- data/lib/active_record/sanitization.rb +9 -6
- data/lib/active_record/schema_dumper.rb +18 -11
- data/lib/active_record/schema_migration.rb +2 -1
- data/lib/active_record/scoping/named.rb +5 -2
- data/lib/active_record/scoping.rb +0 -1
- data/lib/active_record/signed_id.rb +43 -15
- data/lib/active_record/statement_cache.rb +24 -20
- data/lib/active_record/store.rb +51 -22
- data/lib/active_record/structured_event_subscriber.rb +85 -0
- data/lib/active_record/table_metadata.rb +6 -23
- data/lib/active_record/tasks/abstract_tasks.rb +76 -0
- data/lib/active_record/tasks/database_tasks.rb +85 -85
- data/lib/active_record/tasks/mysql_database_tasks.rb +3 -42
- data/lib/active_record/tasks/postgresql_database_tasks.rb +7 -40
- data/lib/active_record/tasks/sqlite_database_tasks.rb +16 -28
- data/lib/active_record/test_databases.rb +14 -4
- data/lib/active_record/test_fixtures.rb +39 -2
- data/lib/active_record/testing/query_assertions.rb +8 -2
- data/lib/active_record/timestamp.rb +4 -2
- data/lib/active_record/token_for.rb +1 -1
- data/lib/active_record/transaction.rb +2 -5
- data/lib/active_record/transactions.rb +37 -16
- data/lib/active_record/type/hash_lookup_type_map.rb +2 -1
- data/lib/active_record/type/internal/timezone.rb +7 -0
- data/lib/active_record/type/json.rb +13 -2
- data/lib/active_record/type/serialized.rb +16 -4
- data/lib/active_record/type/type_map.rb +1 -1
- data/lib/active_record/type_caster/connection.rb +2 -1
- data/lib/active_record/validations/associated.rb +1 -1
- data/lib/active_record/validations/uniqueness.rb +8 -8
- data/lib/active_record.rb +84 -49
- data/lib/arel/alias_predication.rb +2 -0
- data/lib/arel/collectors/bind.rb +2 -2
- data/lib/arel/collectors/sql_string.rb +1 -1
- data/lib/arel/collectors/substitute_binds.rb +2 -2
- data/lib/arel/crud.rb +6 -11
- data/lib/arel/nodes/binary.rb +1 -1
- data/lib/arel/nodes/count.rb +2 -2
- data/lib/arel/nodes/function.rb +4 -10
- data/lib/arel/nodes/named_function.rb +2 -2
- data/lib/arel/nodes/node.rb +2 -2
- data/lib/arel/nodes/sql_literal.rb +1 -1
- data/lib/arel/nodes.rb +0 -2
- data/lib/arel/predications.rb +1 -3
- data/lib/arel/select_manager.rb +7 -2
- data/lib/arel/table.rb +3 -7
- data/lib/arel/visitors/dot.rb +0 -3
- data/lib/arel/visitors/postgresql.rb +55 -0
- data/lib/arel/visitors/sqlite.rb +55 -8
- data/lib/arel/visitors/to_sql.rb +3 -21
- data/lib/arel.rb +3 -1
- data/lib/rails/generators/active_record/application_record/USAGE +1 -1
- metadata +16 -13
- data/lib/active_record/explain_subscriber.rb +0 -34
- data/lib/active_record/normalization.rb +0 -163
- data/lib/active_record/relation/record_fetch_warning.rb +0 -52
|
@@ -2,40 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
module ActiveRecord
|
|
4
4
|
module QueryLogs
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
# Formats the key value pairs into a string.
|
|
11
|
-
def format(pairs)
|
|
12
|
-
pairs.map! do |key, value|
|
|
13
|
-
"#{key}#{key_value_separator}#{format_value(value)}"
|
|
14
|
-
end.join(",")
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
attr_reader :key_value_separator
|
|
19
|
-
|
|
20
|
-
def format_value(value)
|
|
21
|
-
value
|
|
5
|
+
module LegacyFormatter # :nodoc:
|
|
6
|
+
class << self
|
|
7
|
+
# Formats the key value pairs into a string.
|
|
8
|
+
def format(key, value)
|
|
9
|
+
"#{key}:#{value}"
|
|
22
10
|
end
|
|
23
|
-
end
|
|
24
11
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
def join(pairs)
|
|
13
|
+
pairs.join(",")
|
|
14
|
+
end
|
|
28
15
|
end
|
|
16
|
+
end
|
|
29
17
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
18
|
+
class SQLCommenter # :nodoc:
|
|
19
|
+
class << self
|
|
20
|
+
def format(key, value)
|
|
21
|
+
"#{key}='#{ERB::Util.url_encode(value)}'"
|
|
22
|
+
end
|
|
34
23
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"'#{ERB::Util.url_encode(value)}'"
|
|
24
|
+
def join(pairs)
|
|
25
|
+
pairs.join(",")
|
|
38
26
|
end
|
|
27
|
+
end
|
|
39
28
|
end
|
|
40
29
|
end
|
|
41
30
|
end
|
|
@@ -56,12 +56,10 @@ module ActiveRecord
|
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
# Same as #find_by_sql but perform the query asynchronously and returns an ActiveRecord::Promise.
|
|
59
|
-
def async_find_by_sql(sql, binds = [], preparable: nil, &block)
|
|
60
|
-
|
|
61
|
-
_query_by_sql(c, sql, binds, preparable: preparable, async: true)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
result.then do |result|
|
|
59
|
+
def async_find_by_sql(sql, binds = [], preparable: nil, allow_retry: false, &block)
|
|
60
|
+
with_connection do |c|
|
|
61
|
+
_query_by_sql(c, sql, binds, preparable: preparable, allow_retry: allow_retry, async: true)
|
|
62
|
+
end.then do |result|
|
|
65
63
|
_load_from_sql(result, &block)
|
|
66
64
|
end
|
|
67
65
|
end
|
|
@@ -71,6 +69,8 @@ module ActiveRecord
|
|
|
71
69
|
end
|
|
72
70
|
|
|
73
71
|
def _load_from_sql(result_set, &block) # :nodoc:
|
|
72
|
+
return [] if result_set.empty?
|
|
73
|
+
|
|
74
74
|
column_types = result_set.column_types
|
|
75
75
|
|
|
76
76
|
unless column_types.empty?
|
|
@@ -86,10 +86,10 @@ module ActiveRecord
|
|
|
86
86
|
|
|
87
87
|
message_bus.instrument("instantiation.active_record", payload) do
|
|
88
88
|
if result_set.includes_column?(inheritance_column)
|
|
89
|
-
result_set.map { |record| instantiate(record, column_types, &block) }
|
|
89
|
+
result_set.indexed_rows.map { |record| instantiate(record, column_types, &block) }
|
|
90
90
|
else
|
|
91
91
|
# Instantiate a homogeneous set
|
|
92
|
-
result_set.map { |record| instantiate_instance_of(self, record, column_types, &block) }
|
|
92
|
+
result_set.indexed_rows.map { |record| instantiate_instance_of(self, record, column_types, &block) }
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "active_record"
|
|
4
3
|
require "rails"
|
|
4
|
+
require "active_record"
|
|
5
5
|
require "active_support/core_ext/object/try"
|
|
6
6
|
require "active_model/railtie"
|
|
7
7
|
|
|
@@ -35,9 +35,12 @@ module ActiveRecord
|
|
|
35
35
|
config.active_record.query_log_tags = [ :application ]
|
|
36
36
|
config.active_record.query_log_tags_format = :legacy
|
|
37
37
|
config.active_record.cache_query_log_tags = false
|
|
38
|
+
config.active_record.query_log_tags_prepend_comment = false
|
|
38
39
|
config.active_record.raise_on_assign_to_attr_readonly = false
|
|
39
40
|
config.active_record.belongs_to_required_validates_foreign_key = true
|
|
40
41
|
config.active_record.generate_secure_token_on = :create
|
|
42
|
+
config.active_record.use_legacy_signed_id_verifier = :generate_and_verify
|
|
43
|
+
config.active_record.deprecated_associations_options = { mode: :warn, backtrace: false }
|
|
41
44
|
|
|
42
45
|
config.active_record.queues = ActiveSupport::InheritableOptions.new
|
|
43
46
|
|
|
@@ -184,30 +187,6 @@ To keep using the current cache store, you can turn off cache versioning entirel
|
|
|
184
187
|
end
|
|
185
188
|
end
|
|
186
189
|
|
|
187
|
-
initializer "active_record.warn_on_records_fetched_greater_than" do
|
|
188
|
-
if config.active_record.warn_on_records_fetched_greater_than
|
|
189
|
-
ActiveRecord.deprecator.warn <<~MSG.squish
|
|
190
|
-
`config.active_record.warn_on_records_fetched_greater_than` is deprecated and will be
|
|
191
|
-
removed in Rails 8.0.
|
|
192
|
-
Please subscribe to `sql.active_record` notifications and access the row count field to
|
|
193
|
-
detect large result set sizes.
|
|
194
|
-
MSG
|
|
195
|
-
ActiveSupport.on_load(:active_record) do
|
|
196
|
-
require "active_record/relation/record_fetch_warning"
|
|
197
|
-
end
|
|
198
|
-
end
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
initializer "active_record.sqlite3_deprecated_warning" do
|
|
202
|
-
if config.active_record.key?(:sqlite3_production_warning)
|
|
203
|
-
config.active_record.delete(:sqlite3_production_warning)
|
|
204
|
-
ActiveRecord.deprecator.warn <<~MSG.squish
|
|
205
|
-
The `config.active_record.sqlite3_production_warning` configuration no longer has any effect
|
|
206
|
-
and can be safely removed.
|
|
207
|
-
MSG
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
190
|
initializer "active_record.sqlite3_adapter_strict_strings_by_default" do
|
|
212
191
|
config.after_initialize do
|
|
213
192
|
if config.active_record.sqlite3_adapter_strict_strings_by_default
|
|
@@ -253,10 +232,12 @@ To keep using the current cache store, you can turn off cache versioning entirel
|
|
|
253
232
|
:query_log_tags,
|
|
254
233
|
:query_log_tags_format,
|
|
255
234
|
:cache_query_log_tags,
|
|
235
|
+
:query_log_tags_prepend_comment,
|
|
256
236
|
:sqlite3_adapter_strict_strings_by_default,
|
|
257
237
|
:check_schema_cache_dump_version,
|
|
258
238
|
:use_schema_cache_dump,
|
|
259
239
|
:postgresql_adapter_decode_dates,
|
|
240
|
+
:use_legacy_signed_id_verifier,
|
|
260
241
|
)
|
|
261
242
|
|
|
262
243
|
configs_used_in_other_initializers.each do |k, v|
|
|
@@ -298,6 +279,13 @@ To keep using the current cache store, you can turn off cache versioning entirel
|
|
|
298
279
|
end
|
|
299
280
|
end
|
|
300
281
|
|
|
282
|
+
initializer "active_record.job_checkpoints" do
|
|
283
|
+
require "active_record/railties/job_checkpoints"
|
|
284
|
+
ActiveSupport.on_load(:active_job_continuable) do
|
|
285
|
+
prepend ActiveRecord::Railties::JobCheckpoints
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
301
289
|
initializer "active_record.set_reloader_hooks" do
|
|
302
290
|
ActiveSupport.on_load(:active_record) do
|
|
303
291
|
ActiveSupport::Reloader.before_class_unload do
|
|
@@ -343,9 +331,22 @@ To keep using the current cache store, you can turn off cache versioning entirel
|
|
|
343
331
|
end
|
|
344
332
|
end
|
|
345
333
|
|
|
346
|
-
initializer "active_record.
|
|
347
|
-
|
|
348
|
-
|
|
334
|
+
initializer "active_record.filter_attributes_as_log_parameters" do |app|
|
|
335
|
+
ActiveRecord::FilterAttributeHandler.new(app).enable
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
initializer "active_record.configure_message_verifiers" do |app|
|
|
339
|
+
ActiveRecord.message_verifiers = app.message_verifiers
|
|
340
|
+
|
|
341
|
+
use_legacy_signed_id_verifier = app.config.active_record.use_legacy_signed_id_verifier
|
|
342
|
+
legacy_options = { digest: "SHA256", serializer: JSON, url_safe: true }
|
|
343
|
+
|
|
344
|
+
if use_legacy_signed_id_verifier == :generate_and_verify
|
|
345
|
+
app.message_verifiers.prepend { |salt| legacy_options if salt == "active_record/signed_id" }
|
|
346
|
+
elsif use_legacy_signed_id_verifier == :verify
|
|
347
|
+
app.message_verifiers.rotate { |salt| legacy_options if salt == "active_record/signed_id" }
|
|
348
|
+
elsif use_legacy_signed_id_verifier
|
|
349
|
+
raise ArgumentError, "Unrecognized value for config.active_record.use_legacy_signed_id_verifier: #{use_legacy_signed_id_verifier.inspect}"
|
|
349
350
|
end
|
|
350
351
|
end
|
|
351
352
|
|
|
@@ -390,7 +391,7 @@ To keep using the current cache store, you can turn off cache versioning entirel
|
|
|
390
391
|
config.after_initialize do
|
|
391
392
|
if app.config.active_record.query_log_tags_enabled
|
|
392
393
|
ActiveRecord.query_transformers << ActiveRecord::QueryLogs
|
|
393
|
-
ActiveRecord::QueryLogs.taggings.merge
|
|
394
|
+
ActiveRecord::QueryLogs.taggings = ActiveRecord::QueryLogs.taggings.merge(
|
|
394
395
|
application: Rails.application.class.name.split("::").first,
|
|
395
396
|
pid: -> { Process.pid.to_s },
|
|
396
397
|
socket: ->(context) { context[:connection].pool.db_config.socket },
|
|
@@ -405,12 +406,16 @@ To keep using the current cache store, you can turn off cache versioning entirel
|
|
|
405
406
|
end
|
|
406
407
|
|
|
407
408
|
if app.config.active_record.query_log_tags_format
|
|
408
|
-
ActiveRecord::QueryLogs.
|
|
409
|
+
ActiveRecord::QueryLogs.tags_formatter = app.config.active_record.query_log_tags_format
|
|
409
410
|
end
|
|
410
411
|
|
|
411
412
|
if app.config.active_record.cache_query_log_tags
|
|
412
413
|
ActiveRecord::QueryLogs.cache_query_log_tags = true
|
|
413
414
|
end
|
|
415
|
+
|
|
416
|
+
if app.config.active_record.query_log_tags_prepend_comment
|
|
417
|
+
ActiveRecord::QueryLogs.prepend_comment = true
|
|
418
|
+
end
|
|
414
419
|
end
|
|
415
420
|
end
|
|
416
421
|
end
|
|
@@ -41,11 +41,14 @@ module ActiveRecord
|
|
|
41
41
|
|
|
42
42
|
def cleanup_view_runtime
|
|
43
43
|
if logger && logger.info?
|
|
44
|
-
|
|
44
|
+
runtime_stats = ActiveRecord::RuntimeRegistry.stats
|
|
45
|
+
db_rt_before_render = runtime_stats.reset_runtimes
|
|
45
46
|
self.db_runtime = (db_runtime || 0) + db_rt_before_render
|
|
47
|
+
|
|
46
48
|
runtime = super
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
|
|
50
|
+
queries_rt = runtime_stats.sql_runtime - runtime_stats.async_sql_runtime
|
|
51
|
+
db_rt_after_render = runtime_stats.reset_runtimes
|
|
49
52
|
self.db_runtime += db_rt_after_render
|
|
50
53
|
runtime - queries_rt
|
|
51
54
|
else
|
|
@@ -56,9 +59,11 @@ module ActiveRecord
|
|
|
56
59
|
def append_info_to_payload(payload)
|
|
57
60
|
super
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
payload[:
|
|
61
|
-
payload[:
|
|
62
|
+
runtime_stats = ActiveRecord::RuntimeRegistry.stats
|
|
63
|
+
payload[:db_runtime] = (db_runtime || 0) + runtime_stats.sql_runtime
|
|
64
|
+
payload[:queries_count] = runtime_stats.queries_count
|
|
65
|
+
payload[:cached_queries_count] = runtime_stats.cached_queries_count
|
|
66
|
+
runtime_stats.reset
|
|
62
67
|
end
|
|
63
68
|
end
|
|
64
69
|
end
|
|
@@ -87,22 +87,7 @@ db_namespace = namespace :db do
|
|
|
87
87
|
|
|
88
88
|
desc "Migrate the database (options: VERSION=x, VERBOSE=false, SCOPE=blog)."
|
|
89
89
|
task migrate: :load_config do
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if db_configs.size == 1 && db_configs.first.primary?
|
|
93
|
-
ActiveRecord::Tasks::DatabaseTasks.migrate
|
|
94
|
-
else
|
|
95
|
-
mapped_versions = ActiveRecord::Tasks::DatabaseTasks.db_configs_with_versions
|
|
96
|
-
|
|
97
|
-
mapped_versions.sort.each do |version, db_configs|
|
|
98
|
-
db_configs.each do |db_config|
|
|
99
|
-
ActiveRecord::Tasks::DatabaseTasks.with_temporary_connection(db_config) do
|
|
100
|
-
ActiveRecord::Tasks::DatabaseTasks.migrate(version)
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
90
|
+
ActiveRecord::Tasks::DatabaseTasks.migrate_all
|
|
106
91
|
db_namespace["_dump"].invoke
|
|
107
92
|
end
|
|
108
93
|
|
|
@@ -175,8 +160,20 @@ db_namespace = namespace :db do
|
|
|
175
160
|
end
|
|
176
161
|
end
|
|
177
162
|
|
|
178
|
-
|
|
179
|
-
task reset: ["db:drop", "db:create", "db:migrate"]
|
|
163
|
+
desc "Resets your database using your migrations for the current environment"
|
|
164
|
+
task reset: ["db:drop", "db:create", "db:schema:dump", "db:migrate"]
|
|
165
|
+
|
|
166
|
+
namespace :reset do
|
|
167
|
+
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
|
|
168
|
+
desc "Drop and recreate the #{name} database using migrations"
|
|
169
|
+
task name => :load_config do
|
|
170
|
+
db_namespace["drop:#{name}"].invoke
|
|
171
|
+
db_namespace["create:#{name}"].invoke
|
|
172
|
+
db_namespace["schema:dump:#{name}"].invoke
|
|
173
|
+
db_namespace["migrate:#{name}"].invoke
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
180
177
|
|
|
181
178
|
desc 'Run the "up" for a given migration VERSION.'
|
|
182
179
|
task up: :load_config do
|
|
@@ -348,7 +345,7 @@ db_namespace = namespace :db do
|
|
|
348
345
|
pending_migrations << pool.migration_context.open.pending_migrations
|
|
349
346
|
end
|
|
350
347
|
|
|
351
|
-
pending_migrations
|
|
348
|
+
pending_migrations.flatten!
|
|
352
349
|
|
|
353
350
|
if pending_migrations.any?
|
|
354
351
|
puts "You have #{pending_migrations.size} pending #{pending_migrations.size > 1 ? 'migrations:' : 'migration:'}"
|
|
@@ -462,29 +459,23 @@ db_namespace = namespace :db do
|
|
|
462
459
|
namespace :schema do
|
|
463
460
|
desc "Create a database schema file (either db/schema.rb or db/structure.sql, depending on `ENV['SCHEMA_FORMAT']` or `config.active_record.schema_format`)"
|
|
464
461
|
task dump: :load_config do
|
|
465
|
-
ActiveRecord::Tasks::DatabaseTasks.
|
|
466
|
-
db_config = pool.db_config
|
|
467
|
-
schema_format = ENV.fetch("SCHEMA_FORMAT", ActiveRecord.schema_format).to_sym
|
|
468
|
-
ActiveRecord::Tasks::DatabaseTasks.dump_schema(db_config, schema_format)
|
|
469
|
-
end
|
|
462
|
+
ActiveRecord::Tasks::DatabaseTasks.dump_all
|
|
470
463
|
|
|
471
464
|
db_namespace["schema:dump"].reenable
|
|
472
465
|
end
|
|
473
466
|
|
|
474
467
|
desc "Load a database schema file (either db/schema.rb or db/structure.sql, depending on `ENV['SCHEMA_FORMAT']` or `config.active_record.schema_format`) into the database"
|
|
475
468
|
task load: [:load_config, :check_protected_environments] do
|
|
476
|
-
|
|
477
|
-
ActiveRecord::Tasks::DatabaseTasks.load_schema_current(schema_format, ENV["SCHEMA"])
|
|
469
|
+
ActiveRecord::Tasks::DatabaseTasks.load_schema_current(ENV["SCHEMA_FORMAT"], ENV["SCHEMA"])
|
|
478
470
|
end
|
|
479
471
|
|
|
480
472
|
namespace :dump do
|
|
481
473
|
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
|
|
482
|
-
desc "Create a database schema file (either db/schema.rb or db/structure.sql, depending on
|
|
474
|
+
desc "Create a database schema file (either db/schema.rb or db/structure.sql, depending on configuration) for #{name} database"
|
|
483
475
|
task name => :load_config do
|
|
484
476
|
ActiveRecord::Tasks::DatabaseTasks.with_temporary_pool_for_each(name: name) do |pool|
|
|
485
477
|
db_config = pool.db_config
|
|
486
|
-
|
|
487
|
-
ActiveRecord::Tasks::DatabaseTasks.dump_schema(db_config, schema_format)
|
|
478
|
+
ActiveRecord::Tasks::DatabaseTasks.dump_schema(db_config, ENV["SCHEMA_FORMAT"] || db_config.schema_format)
|
|
488
479
|
end
|
|
489
480
|
|
|
490
481
|
db_namespace["schema:dump:#{name}"].reenable
|
|
@@ -494,12 +485,11 @@ db_namespace = namespace :db do
|
|
|
494
485
|
|
|
495
486
|
namespace :load do
|
|
496
487
|
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name|
|
|
497
|
-
desc "Load a database schema file (either db/schema.rb or db/structure.sql, depending on
|
|
498
|
-
task name =>
|
|
488
|
+
desc "Load a database schema file (either db/schema.rb or db/structure.sql, depending on configuration) into the #{name} database"
|
|
489
|
+
task name => [:load_config, :check_protected_environments] do
|
|
499
490
|
ActiveRecord::Tasks::DatabaseTasks.with_temporary_pool_for_each(name: name) do |pool|
|
|
500
491
|
db_config = pool.db_config
|
|
501
|
-
|
|
502
|
-
ActiveRecord::Tasks::DatabaseTasks.load_schema(db_config, schema_format)
|
|
492
|
+
ActiveRecord::Tasks::DatabaseTasks.load_schema(db_config, ENV["SCHEMA_FORMAT"] || db_config.schema_format)
|
|
503
493
|
end
|
|
504
494
|
end
|
|
505
495
|
end
|
|
@@ -543,13 +533,12 @@ db_namespace = namespace :db do
|
|
|
543
533
|
end
|
|
544
534
|
|
|
545
535
|
namespace :test do
|
|
546
|
-
# desc "Recreate the test database from an existent schema file (schema.rb or structure.sql, depending on
|
|
536
|
+
# desc "Recreate the test database from an existent schema file (schema.rb or structure.sql, depending on configuration)"
|
|
547
537
|
task load_schema: %w(db:test:purge) do
|
|
548
538
|
ActiveRecord::Tasks::DatabaseTasks.with_temporary_pool_for_each(env: "test") do |pool|
|
|
549
539
|
db_config = pool.db_config
|
|
550
540
|
ActiveRecord::Schema.verbose = false
|
|
551
|
-
|
|
552
|
-
ActiveRecord::Tasks::DatabaseTasks.load_schema(db_config, schema_format)
|
|
541
|
+
ActiveRecord::Tasks::DatabaseTasks.load_schema(db_config, ENV["SCHEMA_FORMAT"] || db_config.schema_format)
|
|
553
542
|
end
|
|
554
543
|
end
|
|
555
544
|
|
|
@@ -574,8 +563,7 @@ db_namespace = namespace :db do
|
|
|
574
563
|
ActiveRecord::Tasks::DatabaseTasks.with_temporary_pool_for_each(env: "test", name: name) do |pool|
|
|
575
564
|
db_config = pool.db_config
|
|
576
565
|
ActiveRecord::Schema.verbose = false
|
|
577
|
-
|
|
578
|
-
ActiveRecord::Tasks::DatabaseTasks.load_schema(db_config, schema_format)
|
|
566
|
+
ActiveRecord::Tasks::DatabaseTasks.load_schema(db_config, ENV["SCHEMA_FORMAT"] || db_config.schema_format)
|
|
579
567
|
end
|
|
580
568
|
end
|
|
581
569
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ActiveRecord
|
|
4
|
+
module Railties # :nodoc:
|
|
5
|
+
module JobCheckpoints # :nodoc:
|
|
6
|
+
def checkpoint!
|
|
7
|
+
if ActiveRecord.all_open_transactions.any?
|
|
8
|
+
raise ActiveJob::Continuation::CheckpointError, "Cannot checkpoint job with open transactions"
|
|
9
|
+
else
|
|
10
|
+
super
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -5,19 +5,18 @@ require "active_record/runtime_registry"
|
|
|
5
5
|
module ActiveRecord
|
|
6
6
|
module Railties # :nodoc:
|
|
7
7
|
module JobRuntime # :nodoc:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
result
|
|
16
|
-
end
|
|
17
|
-
else
|
|
18
|
-
super
|
|
8
|
+
def instrument(operation, payload = {}, &block) # :nodoc:
|
|
9
|
+
if operation == :perform && block
|
|
10
|
+
super(operation, payload) do
|
|
11
|
+
db_runtime_before_perform = ActiveRecord::RuntimeRegistry.stats.sql_runtime
|
|
12
|
+
result = block.call
|
|
13
|
+
payload[:db_runtime] = ActiveRecord::RuntimeRegistry.stats.sql_runtime - db_runtime_before_perform
|
|
14
|
+
result
|
|
19
15
|
end
|
|
16
|
+
else
|
|
17
|
+
super
|
|
20
18
|
end
|
|
19
|
+
end
|
|
21
20
|
end
|
|
22
21
|
end
|
|
23
22
|
end
|
|
@@ -198,7 +198,7 @@ module ActiveRecord
|
|
|
198
198
|
end
|
|
199
199
|
|
|
200
200
|
def join_scope(table, foreign_table, foreign_klass)
|
|
201
|
-
predicate_builder = predicate_builder(table)
|
|
201
|
+
predicate_builder = klass.predicate_builder.with(TableMetadata.new(klass, table))
|
|
202
202
|
scope_chain_items = join_scopes(table, predicate_builder)
|
|
203
203
|
klass_scope = klass_join_scope(table, predicate_builder)
|
|
204
204
|
|
|
@@ -224,7 +224,7 @@ module ActiveRecord
|
|
|
224
224
|
klass_scope
|
|
225
225
|
end
|
|
226
226
|
|
|
227
|
-
def join_scopes(table, predicate_builder, klass = self.klass, record = nil) # :nodoc:
|
|
227
|
+
def join_scopes(table, predicate_builder = nil, klass = self.klass, record = nil) # :nodoc:
|
|
228
228
|
if scope
|
|
229
229
|
[scope_for(build_scope(table, predicate_builder, klass), record)]
|
|
230
230
|
else
|
|
@@ -232,7 +232,7 @@ module ActiveRecord
|
|
|
232
232
|
end
|
|
233
233
|
end
|
|
234
234
|
|
|
235
|
-
def klass_join_scope(table, predicate_builder) # :nodoc:
|
|
235
|
+
def klass_join_scope(table, predicate_builder = nil) # :nodoc:
|
|
236
236
|
relation = build_scope(table, predicate_builder)
|
|
237
237
|
klass.scope_for_association(relation)
|
|
238
238
|
end
|
|
@@ -333,12 +333,8 @@ module ActiveRecord
|
|
|
333
333
|
collect_join_chain
|
|
334
334
|
end
|
|
335
335
|
|
|
336
|
-
def build_scope(table, predicate_builder =
|
|
337
|
-
Relation.create(
|
|
338
|
-
klass,
|
|
339
|
-
table: table,
|
|
340
|
-
predicate_builder: predicate_builder
|
|
341
|
-
)
|
|
336
|
+
def build_scope(table, predicate_builder = nil, klass = self.klass)
|
|
337
|
+
Relation.create(klass, table:, predicate_builder:)
|
|
342
338
|
end
|
|
343
339
|
|
|
344
340
|
def strict_loading?
|
|
@@ -357,10 +353,6 @@ module ActiveRecord
|
|
|
357
353
|
end
|
|
358
354
|
|
|
359
355
|
private
|
|
360
|
-
def predicate_builder(table)
|
|
361
|
-
PredicateBuilder.new(TableMetadata.new(klass, table))
|
|
362
|
-
end
|
|
363
|
-
|
|
364
356
|
def primary_key(klass)
|
|
365
357
|
klass.primary_key || raise(UnknownPrimaryKey.new(klass))
|
|
366
358
|
end
|
|
@@ -524,6 +516,8 @@ module ActiveRecord
|
|
|
524
516
|
|
|
525
517
|
def initialize(name, scope, options, active_record)
|
|
526
518
|
super
|
|
519
|
+
|
|
520
|
+
@validated = false
|
|
527
521
|
@type = -(options[:foreign_type]&.to_s || "#{options[:as]}_type") if options[:as]
|
|
528
522
|
@foreign_type = -(options[:foreign_type]&.to_s || "#{name}_type") if options[:polymorphic]
|
|
529
523
|
@join_table = nil
|
|
@@ -531,9 +525,9 @@ module ActiveRecord
|
|
|
531
525
|
@association_foreign_key = nil
|
|
532
526
|
@association_primary_key = nil
|
|
533
527
|
if options[:query_constraints]
|
|
534
|
-
|
|
535
|
-
Setting `query_constraints:` option on `#{active_record}.#{macro} :#{name}` is
|
|
536
|
-
To
|
|
528
|
+
raise ConfigurationError, <<~MSG.squish
|
|
529
|
+
Setting `query_constraints:` option on `#{active_record}.#{macro} :#{name}` is not allowed.
|
|
530
|
+
To get the same behavior, use the `foreign_key` option instead.
|
|
537
531
|
MSG
|
|
538
532
|
end
|
|
539
533
|
|
|
@@ -542,6 +536,8 @@ module ActiveRecord
|
|
|
542
536
|
options[:query_constraints] = options.delete(:foreign_key)
|
|
543
537
|
end
|
|
544
538
|
|
|
539
|
+
@deprecated = !!options[:deprecated]
|
|
540
|
+
|
|
545
541
|
ensure_option_not_given_as_class!(:class_name)
|
|
546
542
|
end
|
|
547
543
|
|
|
@@ -562,12 +558,12 @@ module ActiveRecord
|
|
|
562
558
|
def foreign_key(infer_from_inverse_of: true)
|
|
563
559
|
@foreign_key ||= if options[:foreign_key]
|
|
564
560
|
if options[:foreign_key].is_a?(Array)
|
|
565
|
-
options[:foreign_key].map { |fk| fk.to_s.freeze }.freeze
|
|
561
|
+
options[:foreign_key].map { |fk| -fk.to_s.freeze }.freeze
|
|
566
562
|
else
|
|
567
563
|
options[:foreign_key].to_s.freeze
|
|
568
564
|
end
|
|
569
565
|
elsif options[:query_constraints]
|
|
570
|
-
options[:query_constraints].map { |fk| fk.to_s.freeze }.freeze
|
|
566
|
+
options[:query_constraints].map { |fk| -fk.to_s.freeze }.freeze
|
|
571
567
|
else
|
|
572
568
|
derived_fk = derive_foreign_key(infer_from_inverse_of: infer_from_inverse_of)
|
|
573
569
|
|
|
@@ -575,7 +571,12 @@ module ActiveRecord
|
|
|
575
571
|
derived_fk = derive_fk_query_constraints(derived_fk)
|
|
576
572
|
end
|
|
577
573
|
|
|
578
|
-
derived_fk
|
|
574
|
+
if derived_fk.is_a?(Array)
|
|
575
|
+
derived_fk.map! { |fk| -fk.freeze }
|
|
576
|
+
derived_fk.freeze
|
|
577
|
+
else
|
|
578
|
+
-derived_fk.freeze
|
|
579
|
+
end
|
|
579
580
|
end
|
|
580
581
|
end
|
|
581
582
|
|
|
@@ -619,6 +620,8 @@ module ActiveRecord
|
|
|
619
620
|
end
|
|
620
621
|
|
|
621
622
|
def check_validity!
|
|
623
|
+
return if @validated
|
|
624
|
+
|
|
622
625
|
check_validity_of_inverse!
|
|
623
626
|
|
|
624
627
|
if !polymorphic? && (klass.composite_primary_key? || active_record.composite_primary_key?)
|
|
@@ -628,6 +631,8 @@ module ActiveRecord
|
|
|
628
631
|
raise CompositePrimaryKeyMismatchError.new(self)
|
|
629
632
|
end
|
|
630
633
|
end
|
|
634
|
+
|
|
635
|
+
@validated = true
|
|
631
636
|
end
|
|
632
637
|
|
|
633
638
|
def check_eager_loadable!
|
|
@@ -745,6 +750,10 @@ module ActiveRecord
|
|
|
745
750
|
Array(options[:extend])
|
|
746
751
|
end
|
|
747
752
|
|
|
753
|
+
def deprecated?
|
|
754
|
+
@deprecated
|
|
755
|
+
end
|
|
756
|
+
|
|
748
757
|
private
|
|
749
758
|
# Attempts to find the inverse association name automatically.
|
|
750
759
|
# If it cannot find a suitable inverse association name, it returns
|
|
@@ -978,6 +987,8 @@ module ActiveRecord
|
|
|
978
987
|
|
|
979
988
|
def initialize(delegate_reflection)
|
|
980
989
|
super()
|
|
990
|
+
|
|
991
|
+
@validated = false
|
|
981
992
|
@delegate_reflection = delegate_reflection
|
|
982
993
|
@klass = delegate_reflection.options[:anonymous_class]
|
|
983
994
|
@source_reflection_name = delegate_reflection.options[:source]
|
|
@@ -1065,7 +1076,7 @@ module ActiveRecord
|
|
|
1065
1076
|
source_reflection.scopes + super
|
|
1066
1077
|
end
|
|
1067
1078
|
|
|
1068
|
-
def join_scopes(table, predicate_builder, klass = self.klass, record = nil) # :nodoc:
|
|
1079
|
+
def join_scopes(table, predicate_builder = nil, klass = self.klass, record = nil) # :nodoc:
|
|
1069
1080
|
source_reflection.join_scopes(table, predicate_builder, klass, record) + super
|
|
1070
1081
|
end
|
|
1071
1082
|
|
|
@@ -1141,6 +1152,8 @@ module ActiveRecord
|
|
|
1141
1152
|
end
|
|
1142
1153
|
|
|
1143
1154
|
def check_validity!
|
|
1155
|
+
return if @validated
|
|
1156
|
+
|
|
1144
1157
|
if through_reflection.nil?
|
|
1145
1158
|
raise HasManyThroughAssociationNotFoundError.new(active_record, self)
|
|
1146
1159
|
end
|
|
@@ -1178,6 +1191,8 @@ module ActiveRecord
|
|
|
1178
1191
|
end
|
|
1179
1192
|
|
|
1180
1193
|
check_validity_of_inverse!
|
|
1194
|
+
|
|
1195
|
+
@validated = true
|
|
1181
1196
|
end
|
|
1182
1197
|
|
|
1183
1198
|
def constraints
|
|
@@ -1198,6 +1213,10 @@ module ActiveRecord
|
|
|
1198
1213
|
collect_join_reflections(seed + [self])
|
|
1199
1214
|
end
|
|
1200
1215
|
|
|
1216
|
+
def deprecated_nested_reflections
|
|
1217
|
+
@deprecated_nested_reflections ||= collect_deprecated_nested_reflections
|
|
1218
|
+
end
|
|
1219
|
+
|
|
1201
1220
|
protected
|
|
1202
1221
|
def actual_source_reflection # FIXME: this is a horrible name
|
|
1203
1222
|
source_reflection.actual_source_reflection
|
|
@@ -1222,6 +1241,19 @@ module ActiveRecord
|
|
|
1222
1241
|
options[:source_type] || source_reflection.class_name
|
|
1223
1242
|
end
|
|
1224
1243
|
|
|
1244
|
+
def collect_deprecated_nested_reflections
|
|
1245
|
+
result = []
|
|
1246
|
+
[through_reflection, source_reflection].each do |reflection|
|
|
1247
|
+
result << reflection if reflection.deprecated?
|
|
1248
|
+
# Both the through and the source reflections could be through
|
|
1249
|
+
# themselves. Nesting can go an arbitrary number of levels down.
|
|
1250
|
+
if reflection.through_reflection?
|
|
1251
|
+
result.concat(reflection.deprecated_nested_reflections)
|
|
1252
|
+
end
|
|
1253
|
+
end
|
|
1254
|
+
result
|
|
1255
|
+
end
|
|
1256
|
+
|
|
1225
1257
|
delegate_methods = AssociationReflection.public_instance_methods -
|
|
1226
1258
|
public_instance_methods
|
|
1227
1259
|
|
|
@@ -1238,7 +1270,7 @@ module ActiveRecord
|
|
|
1238
1270
|
@previous_reflection = previous_reflection
|
|
1239
1271
|
end
|
|
1240
1272
|
|
|
1241
|
-
def join_scopes(table, predicate_builder, klass = self.klass, record = nil) # :nodoc:
|
|
1273
|
+
def join_scopes(table, predicate_builder = nil, klass = self.klass, record = nil) # :nodoc:
|
|
1242
1274
|
scopes = super
|
|
1243
1275
|
unless @previous_reflection.through_reflection?
|
|
1244
1276
|
scopes += @previous_reflection.join_scopes(table, predicate_builder, klass, record)
|