Module: ActiveRecord

Extended by:
ActiveSupport::Autoload
Defined in:
activerecord/lib/active_record/base.rb,
activerecord/lib/active_record.rb,
activerecord/lib/active_record/core.rb,
activerecord/lib/active_record/enum.rb,
activerecord/lib/active_record/type.rb,
activerecord/lib/active_record/store.rb,
activerecord/lib/active_record/errors.rb,
activerecord/lib/active_record/result.rb,
activerecord/lib/active_record/schema.rb,
activerecord/lib/active_record/explain.rb,
activerecord/lib/active_record/railtie.rb,
activerecord/lib/active_record/scoping.rb,
activerecord/lib/active_record/version.rb,
activerecord/lib/active_record/fixtures.rb,
activerecord/lib/active_record/querying.rb,
activerecord/lib/active_record/relation.rb,
activerecord/lib/active_record/callbacks.rb,
activerecord/lib/active_record/migration.rb,
activerecord/lib/active_record/signed_id.rb,
activerecord/lib/active_record/timestamp.rb,
activerecord/lib/active_record/type/date.rb,
activerecord/lib/active_record/type/json.rb,
activerecord/lib/active_record/type/text.rb,
activerecord/lib/active_record/type/time.rb,
activerecord/lib/active_record/attributes.rb,
activerecord/lib/active_record/encryption.rb,
activerecord/lib/active_record/insert_all.rb,
activerecord/lib/active_record/reflection.rb,
activerecord/lib/active_record/suppressor.rb,
activerecord/lib/active_record/coders/json.rb,
activerecord/lib/active_record/gem_version.rb,
activerecord/lib/active_record/inheritance.rb,
activerecord/lib/active_record/integration.rb,
activerecord/lib/active_record/no_touching.rb,
activerecord/lib/active_record/persistence.rb,
activerecord/lib/active_record/query_cache.rb,
activerecord/lib/active_record/touch_later.rb,
activerecord/lib/active_record/translation.rb,
activerecord/lib/active_record/type_caster.rb,
activerecord/lib/active_record/validations.rb,
activerecord/lib/active_record/aggregations.rb,
activerecord/lib/active_record/associations.rb,
activerecord/lib/active_record/model_schema.rb,
activerecord/lib/active_record/sanitization.rb,
activerecord/lib/active_record/secure_token.rb,
activerecord/lib/active_record/transactions.rb,
activerecord/lib/active_record/counter_cache.rb,
activerecord/lib/active_record/future_result.rb,
activerecord/lib/active_record/null_relation.rb,
activerecord/lib/active_record/schema_dumper.rb,
activerecord/lib/active_record/scoping/named.rb,
activerecord/lib/active_record/serialization.rb,
activerecord/lib/active_record/test_fixtures.rb,
activerecord/lib/active_record/type/type_map.rb,
activerecord/lib/active_record/delegated_type.rb,
activerecord/lib/active_record/encryption/key.rb,
activerecord/lib/active_record/log_subscriber.rb,
activerecord/lib/active_record/table_metadata.rb,
activerecord/lib/active_record/test_databases.rb,
activerecord/lib/active_record/type/date_time.rb,
activerecord/lib/active_record/relation/merger.rb,
activerecord/lib/active_record/scoping/default.rb,
activerecord/lib/active_record/statement_cache.rb,
activerecord/lib/active_record/type/serialized.rb,
activerecord/lib/active_record/type_caster/map.rb,
activerecord/lib/active_record/dynamic_matchers.rb,
activerecord/lib/active_record/explain_registry.rb,
activerecord/lib/active_record/fixture_set/file.rb,
activerecord/lib/active_record/relation/batches.rb,
activerecord/lib/active_record/runtime_registry.rb,
activerecord/lib/active_record/schema_migration.rb,
activerecord/lib/rails/generators/active_record.rb,
activerecord/lib/active_record/attribute_methods.rb,
activerecord/lib/active_record/encryption/cipher.rb,
activerecord/lib/active_record/encryption/config.rb,
activerecord/lib/active_record/encryption/errors.rb,
activerecord/lib/active_record/encryption/scheme.rb,
activerecord/lib/active_record/internal_metadata.rb,
activerecord/lib/active_record/nested_attributes.rb,
activerecord/lib/active_record/coders/yaml_column.rb,
activerecord/lib/active_record/encryption/context.rb,
activerecord/lib/active_record/encryption/message.rb,
activerecord/lib/active_record/explain_subscriber.rb,
activerecord/lib/active_record/locking/optimistic.rb,
activerecord/lib/active_record/validations/length.rb,
activerecord/lib/active_record/connection_adapters.rb,
activerecord/lib/active_record/connection_handling.rb,
activerecord/lib/active_record/encryption/contexts.rb,
activerecord/lib/active_record/legacy_yaml_adapter.rb,
activerecord/lib/active_record/locking/pessimistic.rb,
activerecord/lib/active_record/readonly_attributes.rb,
activerecord/lib/active_record/relation/delegation.rb,
activerecord/lib/active_record/validations/absence.rb,
activerecord/lib/active_record/association_relation.rb,
activerecord/lib/active_record/attribute_assignment.rb,
activerecord/lib/active_record/autosave_association.rb,
activerecord/lib/active_record/encryption/encryptor.rb,
activerecord/lib/active_record/migration/join_table.rb,
activerecord/lib/active_record/relation/from_clause.rb,
activerecord/lib/active_record/tasks/database_tasks.rb,
activerecord/lib/active_record/validations/presence.rb,
activerecord/lib/active_record/encryption/properties.rb,
activerecord/lib/active_record/fixture_set/table_row.rb,
activerecord/lib/active_record/relation/calculations.rb,
activerecord/lib/active_record/relation/where_clause.rb,
activerecord/lib/active_record/type/unsigned_integer.rb,
activerecord/lib/active_record/associations/preloader.rb,
activerecord/lib/active_record/attribute_methods/read.rb,
activerecord/lib/active_record/fixture_set/table_rows.rb,
activerecord/lib/active_record/relation/query_methods.rb,
activerecord/lib/active_record/relation/spawn_methods.rb,
activerecord/lib/active_record/type/internal/timezone.rb,
activerecord/lib/active_record/type_caster/connection.rb,
activerecord/lib/active_record/validations/associated.rb,
activerecord/lib/active_record/validations/uniqueness.rb,
activerecord/lib/active_record/attribute_methods/dirty.rb,
activerecord/lib/active_record/attribute_methods/query.rb,
activerecord/lib/active_record/attribute_methods/write.rb,
activerecord/lib/active_record/database_configurations.rb,
activerecord/lib/active_record/encryption/configurable.rb,
activerecord/lib/active_record/encryption/key_provider.rb,
activerecord/lib/active_record/migration/compatibility.rb,
activerecord/lib/active_record/relation/finder_methods.rb,
activerecord/lib/active_record/associations/association.rb,
activerecord/lib/active_record/encryption/key_generator.rb,
activerecord/lib/active_record/relation/query_attribute.rb,
activerecord/lib/active_record/testing/query_assertions.rb,
activerecord/lib/active_record/validations/numericality.rb,
activerecord/lib/active_record/encryption/null_encryptor.rb,
activerecord/lib/active_record/type/hash_lookup_type_map.rb,
activerecord/lib/active_record/associations/alias_tracker.rb,
activerecord/lib/active_record/connection_adapters/column.rb,
activerecord/lib/active_record/fixture_set/model_metadata.rb,
activerecord/lib/active_record/migration/command_recorder.rb,
activerecord/lib/active_record/relation/predicate_builder.rb,
activerecord/lib/active_record/tasks/mysql_database_tasks.rb,
activerecord/lib/active_record/type/decimal_without_scale.rb,
activerecord/lib/rails/generators/active_record/migration.rb,
activerecord/lib/active_record/railties/controller_runtime.rb,
activerecord/lib/active_record/tasks/sqlite_database_tasks.rb,
activerecord/lib/active_record/associations/join_dependency.rb,
activerecord/lib/active_record/associations/preloader/batch.rb,
activerecord/lib/active_record/asynchronous_queries_tracker.rb,
activerecord/lib/active_record/encryption/cipher/aes256_gcm.rb,
activerecord/lib/active_record/middleware/database_selector.rb,
activerecord/lib/active_record/associations/collection_proxy.rb,
activerecord/lib/active_record/associations/preloader/branch.rb,
activerecord/lib/active_record/attribute_methods/primary_key.rb,
activerecord/lib/active_record/destroy_association_async_job.rb,
activerecord/lib/active_record/encryption/encryptable_record.rb,
activerecord/lib/active_record/encryption/encrypted_fixtures.rb,
activerecord/lib/active_record/encryption/message_serializer.rb,
activerecord/lib/active_record/relation/record_fetch_warning.rb,
activerecord/lib/active_record/associations/association_scope.rb,
activerecord/lib/active_record/type/adapter_specific_registry.rb,
activerecord/lib/active_record/attribute_methods/serialization.rb,
activerecord/lib/active_record/connection_adapters/pool_config.rb,
activerecord/lib/active_record/tasks/postgresql_database_tasks.rb,
activerecord/lib/active_record/associations/has_one_association.rb,
activerecord/lib/active_record/associations/through_association.rb,
activerecord/lib/active_record/connection_adapters/deduplicable.rb,
activerecord/lib/active_record/connection_adapters/mysql/column.rb,
activerecord/lib/active_record/connection_adapters/pool_manager.rb,
activerecord/lib/active_record/connection_adapters/schema_cache.rb,
activerecord/lib/active_record/associations/has_many_association.rb,
activerecord/lib/active_record/associations/singular_association.rb,
activerecord/lib/active_record/connection_adapters/mysql/quoting.rb,
activerecord/lib/active_record/relation/batches/batch_enumerator.rb,
activerecord/lib/active_record/associations/preloader/association.rb,
activerecord/lib/active_record/attribute_methods/before_type_cast.rb,
activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid.rb,
activerecord/lib/active_record/connection_adapters/statement_pool.rb,
activerecord/lib/active_record/database_configurations/url_config.rb,
activerecord/lib/active_record/disable_joins_association_relation.rb,
activerecord/lib/active_record/associations/belongs_to_association.rb,
activerecord/lib/active_record/associations/collection_association.rb,
activerecord/lib/active_record/connection_adapters/sqlite3/quoting.rb,
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb,
activerecord/lib/active_record/database_configurations/hash_config.rb,
activerecord/lib/active_record/encryption/encrypted_attribute_type.rb,
activerecord/lib/active_record/encryption/read_only_null_encryptor.rb,
activerecord/lib/active_record/connection_adapters/abstract/quoting.rb,
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb,
activerecord/lib/active_record/connection_adapters/postgresql/utils.rb,
activerecord/lib/active_record/encryption/encrypting_only_encryptor.rb,
activerecord/lib/active_record/connection_adapters/postgresql/column.rb,
activerecord/lib/active_record/connection_adapters/sql_type_metadata.rb,
activerecord/lib/active_record/encryption/deterministic_key_provider.rb,
activerecord/lib/active_record/middleware/database_selector/resolver.rb,
activerecord/lib/active_record/associations/join_dependency/join_base.rb,
activerecord/lib/active_record/associations/join_dependency/join_part.rb,
activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/bit.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/oid.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/xml.rb,
activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb,
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb,
activerecord/lib/active_record/encryption/derived_secret_key_provider.rb,
activerecord/lib/rails/generators/active_record/model/model_generator.rb,
activerecord/lib/active_record/connection_adapters/abstract/savepoints.rb,
activerecord/lib/active_record/connection_adapters/legacy_pool_manager.rb,
activerecord/lib/active_record/connection_adapters/mysql/schema_dumper.rb,
activerecord/lib/active_record/connection_adapters/mysql/type_metadata.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/cidr.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/date.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/enum.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/inet.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb,
activerecord/lib/active_record/database_configurations/database_config.rb,
activerecord/lib/active_record/associations/has_one_through_association.rb,
activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb,
activerecord/lib/active_record/connection_adapters/abstract/transaction.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/array.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/bytea.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/money.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/point.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/range.rb,
activerecord/lib/active_record/relation/predicate_builder/array_handler.rb,
activerecord/lib/active_record/relation/predicate_builder/range_handler.rb,
activerecord/lib/active_record/associations/has_many_through_association.rb,
activerecord/lib/active_record/connection_adapters/mysql/schema_creation.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/vector.rb,
activerecord/lib/active_record/connection_adapters/sqlite3/schema_dumper.rb,
activerecord/lib/active_record/encryption/extended_deterministic_queries.rb,
activerecord/lib/active_record/associations/preloader/through_association.rb,
activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rb,
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/decimal.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/macaddr.rb,
activerecord/lib/active_record/connection_adapters/mysql/schema_statements.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/interval.rb,
activerecord/lib/active_record/connection_adapters/sqlite3/schema_creation.rb,
activerecord/lib/active_record/encryption/envelope_encryption_key_provider.rb,
activerecord/lib/active_record/relation/predicate_builder/relation_handler.rb,
activerecord/lib/active_record/associations/disable_joins_association_scope.rb,
activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb,
activerecord/lib/active_record/connection_adapters/abstract/database_limits.rb,
activerecord/lib/active_record/connection_adapters/abstract/schema_creation.rb,
activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/date_time.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/timestamp.rb,
activerecord/lib/active_record/connection_adapters/postgresql/schema_dumper.rb,
activerecord/lib/active_record/connection_adapters/postgresql/type_metadata.rb,
activerecord/lib/active_record/associations/join_dependency/join_association.rb,
activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb,
activerecord/lib/active_record/connection_adapters/sqlite3/schema_statements.rb,
activerecord/lib/active_record/middleware/database_selector/resolver/session.rb,
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/bit_varying.rb,
activerecord/lib/active_record/connection_adapters/postgresql/schema_creation.rb,
activerecord/lib/active_record/connection_adapters/sqlite3/schema_definitions.rb,
activerecord/lib/rails/generators/active_record/migration/migration_generator.rb,
activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb,
activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb,
activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/legacy_point.rb,
activerecord/lib/active_record/connection_adapters/sqlite3/database_statements.rb,
activerecord/lib/active_record/database_configurations/connection_url_resolver.rb,
activerecord/lib/active_record/relation/predicate_builder/basic_object_handler.rb,
activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb,
activerecord/lib/active_record/connection_adapters/mysql/explain_pretty_printer.rb,
activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb,
activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb,
activerecord/lib/active_record/connection_adapters/abstract/connection_pool/queue.rb,
activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb,
activerecord/lib/active_record/connection_adapters/sqlite3/explain_pretty_printer.rb,
activerecord/lib/active_record/relation/predicate_builder/association_query_value.rb,
activerecord/lib/active_record/relation/predicate_builder/polymorphic_array_value.rb,
activerecord/lib/active_record/connection_adapters/abstract/connection_pool/reaper.rb,
activerecord/lib/active_record/connection_adapters/postgresql/referential_integrity.rb,
activerecord/lib/active_record/connection_adapters/postgresql/explain_pretty_printer.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/specialized_string.rb,
activerecord/lib/active_record/encryption/extended_deterministic_uniqueness_validator.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/type_map_initializer.rb,
activerecord/lib/active_record/connection_adapters/postgresql/oid/timestamp_with_time_zone.rb,
activerecord/lib/rails/generators/active_record/application_record/application_record_generator.rb

Overview

Automatically expand encrypted arguments to support querying both encrypted and unencrypted data

Active Record Encryption supports querying the db using deterministic attributes. For example:

Contact.find_by(email_address: "[email protected]")

The value “[email protected]” will get encrypted automatically to perform the query. But there is a problem while the data is being encrypted. This won't work. During that time, you need these queries to be:

Contact.find_by(email_address: [ "[email protected]", "<encrypted [email protected]>" ])

This patches ActiveRecord to support this automatically. It addresses both:

  • ActiveRecord::Base: Used in Contact.find_by_email_address(…)

  • ActiveRecord::Relation: Used in Contact.internal.find_by_email_address(…)

ActiveRecord::Base relies on ActiveRecord::Relation (ActiveRecord::QueryMethods) but it does some prepared statements caching. That's why we need to intercept ActiveRecord::Base as soon as it's invoked (so that the proper prepared statement is cached).

When modifying this file run performance tests in test/performance/extended_deterministic_queries_performance_test.rb to

make sure performance overhead is acceptable.

We will extend this to support previous “encryption context” versions in future iterations

Defined Under Namespace

Modules: Aggregations, Associations, AttributeAssignment, AttributeMethods, Attributes, AutosaveAssociation, Batches, Calculations, Callbacks, Coders, ConnectionAdapters, ConnectionHandling, Core, CounterCache, DelegatedType, Delegation, DynamicMatchers, Encryption, Enum, Explain, FinderMethods, Generators, Inheritance, Integration, LegacyYamlAdapter, Locking, Middleware, ModelSchema, NestedAttributes, NoTouching, NullRelation, Persistence, QueryMethods, Querying, Railties, ReadonlyAttributes, Reflection, Sanitization, Scoping, SecureToken, Serialization, SignedId, SpawnMethods, Store, Suppressor, Tasks, TestDatabases, TestFixtures, Testing, Timestamp, TouchLater, Transactions, Translation, Type, TypeCaster, VERSION, Validations Classes: ActiveJobRequiredError, ActiveRecordError, AdapterNotFound, AdapterNotSpecified, AdapterTimeout, AmbiguousSourceReflectionForThroughAssociation, AssociationNotFoundError, AssociationRelation, AssociationTypeMismatch, AsynchronousQueriesTracker, AsynchronousQueryInsideTransactionError, AttributeAssignmentError, Base, ConcurrentMigrationError, ConfigurationError, ConnectionNotEstablished, ConnectionTimeoutError, DangerousAttributeError, DatabaseAlreadyExists, DatabaseConfigurations, Deadlocked, DeleteRestrictionError, DestroyAssociationAsyncError, DestroyAssociationAsyncJob, DisableJoinsAssociationRelation, DuplicateMigrationNameError, DuplicateMigrationVersionError, EagerLoadPolymorphicError, EnvironmentMismatchError, EnvironmentStorageError, ExclusiveConnectionTimeoutError, ExplainRegistry, ExplainSubscriber, Fixture, FixtureClassNotFound, FixtureSet, FutureResult, HasManyThroughAssociationNotFoundError, HasManyThroughAssociationPointlessSourceTypeError, HasManyThroughAssociationPolymorphicSourceError, HasManyThroughAssociationPolymorphicThroughError, HasManyThroughCantAssociateThroughHasOneOrManyReflection, HasManyThroughNestedAssociationsAreReadonly, HasManyThroughOrderError, HasManyThroughSourceAssociationNotFoundError, HasOneAssociationPolymorphicThroughError, HasOneThroughCantAssociateThroughCollection, HasOneThroughCantAssociateThroughHasOneOrManyReflection, HasOneThroughNestedAssociationsAreReadonly, IllegalMigrationNameError, ImmutableRelation, InsertAll, InternalMetadata, InvalidForeignKey, InverseOfAssociationNotFoundError, IrreversibleMigration, IrreversibleOrderError, LockWaitTimeout, LogSubscriber, Migration, MigrationContext, MigrationError, MigrationProxy, Migrator, MismatchedForeignKey, MultiparameterAssignmentErrors, NoDatabaseError, NoEnvironmentInSchemaError, NotNullViolation, PendingMigrationError, Point, PredicateBuilder, PreparedStatementCacheExpired, PreparedStatementInvalid, ProtectedEnvironmentError, QueryAborted, QueryCache, QueryCanceled, Railtie, RangeError, ReadOnlyError, ReadOnlyRecord, RecordInvalid, RecordNotDestroyed, RecordNotFound, RecordNotSaved, RecordNotUnique, Relation, Result, Rollback, RuntimeRegistry, Schema, SchemaDumper, SchemaMigration, SerializationFailure, SerializationTypeMismatch, SoleRecordExceeded, StaleObjectError, StatementCache, StatementInvalid, StatementTimeout, StrictLoadingViolationError, SubclassNotFound, SuppressorRegistry, TableMetadata, TableNotSpecified, ThroughCantAssociateThroughHasOneOrManyReflection, ThroughNestedAssociationsAreReadonly, TransactionIsolationError, TransactionRollbackError, TypeConflictError, UnknownAttributeReference, UnknownMigrationVersionError, UnknownPrimaryKey, ValueTooLong, WrappedDatabaseException

Constant Summary collapse

UnknownAttributeError =

Raised when unknown attributes are supplied via mass assignment.

ActiveModel::UnknownAttributeError

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from ActiveSupport::Autoload

autoload, autoload_at, autoload_under, autoloads, eager_autoload, eager_load!, extended

Instance Attribute Details

#action_on_strict_loading_violationObject

:singleton-method: Set the application to log or raise when an association violates strict loading. Defaults to :raise.


262
263
264
# File 'activerecord/lib/active_record.rb', line 262

def action_on_strict_loading_violation
  @action_on_strict_loading_violation
end

#application_record_classObject

Returns the value of attribute application_record_class


255
256
257
# File 'activerecord/lib/active_record.rb', line 255

def application_record_class
  @application_record_class
end

#async_query_executorObject

Sets the async_query_executor for an application. By default the thread pool executor set to nil which will not run queries in the background. Applications must configure a thread pool executor to use this feature. Options are:

* nil - Does not initialize a thread pool executor. Any async calls will be
run in the foreground.
* :global_thread_pool - Initializes a single +Concurrent::ThreadPoolExecutor+
that uses the +async_query_concurrency+ for the +max_threads+ value.
* :multi_thread_pool - Initializes a +Concurrent::ThreadPoolExecutor+ for each
database connection. The initializer values are defined in the configuration hash.

198
199
200
# File 'activerecord/lib/active_record.rb', line 198

def async_query_executor
  @async_query_executor
end

#default_timezoneObject

:singleton-method: Determines whether to use Time.utc (using :utc) or Time.local (using :local) when pulling dates and times from the database. This is set to :utc by default.


179
180
181
# File 'activerecord/lib/active_record.rb', line 179

def default_timezone
  @default_timezone
end

#dump_schema_after_migrationObject

:singleton-method: Specify whether schema dump should happen at the end of the bin/rails db:migrate command. This is true by default, which is useful for the development environment. This should ideally be false in the production environment where dumping schema is rarely needed.


296
297
298
# File 'activerecord/lib/active_record.rb', line 296

def dump_schema_after_migration
  @dump_schema_after_migration
end

#dump_schemasObject

:singleton-method: Specifies which database schemas to dump when calling db:schema:dump. If the value is :schema_search_path (the default), any schemas listed in schema_search_path are dumped. Use :all to dump all schemas regardless of schema_search_path, or a string of comma separated schemas for a custom list.


306
307
308
# File 'activerecord/lib/active_record.rb', line 306

def dump_schemas
  @dump_schemas
end

#error_on_ignored_orderObject

:singleton-method: Specifies if an error should be raised if the query has an order being ignored when doing batch queries. Useful in applications where the scope being ignored is error-worthy, rather than a warning.


281
282
283
# File 'activerecord/lib/active_record.rb', line 281

def error_on_ignored_order
  @error_on_ignored_order
end

#index_nested_attribute_errorsObject

Returns the value of attribute index_nested_attribute_errors


225
226
227
# File 'activerecord/lib/active_record.rb', line 225

def index_nested_attribute_errors
  @index_nested_attribute_errors
end

#legacy_connection_handlingObject

Returns the value of attribute legacy_connection_handling


172
173
174
# File 'activerecord/lib/active_record.rb', line 172

def legacy_connection_handling
  @legacy_connection_handling
end

#maintain_test_schemaObject

Returns the value of attribute maintain_test_schema


243
244
245
# File 'activerecord/lib/active_record.rb', line 243

def maintain_test_schema
  @maintain_test_schema
end

#queuesObject

:singleton-method:

Specifies the names of the queues used by background jobs.


240
241
242
# File 'activerecord/lib/active_record.rb', line 240

def queues
  @queues
end

#reading_roleObject

Returns the value of attribute reading_role


185
186
187
# File 'activerecord/lib/active_record.rb', line 185

def reading_role
  @reading_role
end

#schema_formatObject

:singleton-method: Specifies the format to use when dumping the database schema with Rails' Rakefile. If :sql, the schema is dumped as (potentially database- specific) SQL statements. If :ruby, the schema is dumped as an ActiveRecord::Schema file which can be loaded into any database that supports migrations. Use :ruby if you want to have different database adapters for, e.g., your development and test environments.


273
274
275
# File 'activerecord/lib/active_record.rb', line 273

def schema_format
  @schema_format
end

#suppress_multiple_database_warningObject

:singleton-method: Show a warning when Rails couldn't parse your database.yml for multiple databases.


313
314
315
# File 'activerecord/lib/active_record.rb', line 313

def suppress_multiple_database_warning
  @suppress_multiple_database_warning
end

#timestamped_migrationsObject

:singleton-method: Specify whether or not to use timestamps for migration versions


287
288
289
# File 'activerecord/lib/active_record.rb', line 287

def timestamped_migrations
  @timestamped_migrations
end

#verbose_query_logsObject

:singleton-method:

Specifies if the methods calling database queries should be logged below their relevant queries. Defaults to false.


233
234
235
# File 'activerecord/lib/active_record.rb', line 233

def verbose_query_logs
  @verbose_query_logs
end

#warn_on_records_fetched_greater_thanObject

:singleton-method: Specify a threshold for the size of query result sets. If the number of records in the set exceeds the threshold, a warning is logged. This can be used to identify queries which load thousands of records and potentially cause memory bloat.


252
253
254
# File 'activerecord/lib/active_record.rb', line 252

def warn_on_records_fetched_greater_than
  @warn_on_records_fetched_greater_than
end

#writing_roleObject

Returns the value of attribute writing_role


182
183
184
# File 'activerecord/lib/active_record.rb', line 182

def writing_role
  @writing_role
end

Class Method Details

.eager_load!Object


316
317
318
319
320
321
322
323
324
# File 'activerecord/lib/active_record.rb', line 316

def self.eager_load!
  super
  ActiveRecord::Locking.eager_load!
  ActiveRecord::Scoping.eager_load!
  ActiveRecord::Associations.eager_load!
  ActiveRecord::AttributeMethods.eager_load!
  ActiveRecord::ConnectionAdapters.eager_load!
  ActiveRecord::Encryption.eager_load!
end

.gem_versionObject

Returns the version of the currently loaded Active Record as a Gem::Version


5
6
7
# File 'activerecord/lib/active_record/gem_version.rb', line 5

def self.gem_version
  Gem::Version.new VERSION::STRING
end

.global_executor_concurrencyObject

:nodoc:


221
222
223
# File 'activerecord/lib/active_record.rb', line 221

def self.global_executor_concurrency # :nodoc:
  @global_executor_concurrency ||= nil
end

.global_executor_concurrency=(global_executor_concurrency) ⇒ Object

Set the global_executor_concurrency. This configuration value can only be used with the global thread pool async query executor.


213
214
215
216
217
218
219
# File 'activerecord/lib/active_record.rb', line 213

def self.global_executor_concurrency=(global_executor_concurrency)
  if self.async_query_executor.nil? || self.async_query_executor == :multi_thread_pool
    raise ArgumentError, "`global_executor_concurrency` cannot be set when using the executor is nil or set to multi_thead_pool. For multiple thread pools, please set the concurrency in your database configuration."
  end

  @global_executor_concurrency = global_executor_concurrency
end

.global_thread_pool_async_query_executorObject

:nodoc:


201
202
203
204
205
206
207
208
209
# File 'activerecord/lib/active_record.rb', line 201

def self.global_thread_pool_async_query_executor # :nodoc:
  concurrency = global_executor_concurrency || 4
  @global_thread_pool_async_query_executor ||= Concurrent::ThreadPoolExecutor.new(
    min_threads: 0,
    max_threads: concurrency,
    max_queue: concurrency * 4,
    fallback_policy: :caller_runs
  )
end

.versionObject

Returns the version of the currently loaded ActiveRecord as a Gem::Version


7
8
9
# File 'activerecord/lib/active_record/version.rb', line 7

def self.version
  gem_version
end