1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/lib/active_record
eileencodes b74fbe4e51
Deprecate "primary" as a connection_specification_name for ActiveRecord::Base
As multiple databases have evolved it's becoming more and more
confusing that we have a `connection_specification_name` that defaults
to "primary" and a `spec_name` on the database objects that defaults to
"primary" (my bad).

Even more confusing is that we use the class name for all
non-ActiveRecord::Base abstract classes that establish connections. For
example connections established on `class MyOtherDatabaseModel <
ApplicationRecord` will use `"MyOtherDatabaseModel"` as it's connection
specification name while `ActiveRecord::Base` uses `"primary"`.

This PR deprecates the use of the name `"primary"` as the
`connection_specification_name` for `ActiveRecord::Base` in favor of
using `"ActiveRecord::Base"`.

In this PR the following is true:

* If `handler.establish_connection(:primary)` is called, `"primary"`
will not throw a deprecation warning and can still be used for the
`connection_specification_name`. This also fixes a bug where using this
method to establish a connection could accidentally overwrite the actual
`ActiveRecord::Base` connection IF that connection was not using a
configuration named `:primary`.
* Calling `handler.retrieve_connection "primary"` when
`handler.establish_connection :primary` has never been called will
return the connection for `ActiveRecord::Base` and throw a deprecation
warning.
* Calling `handler.remove_connection "primary"` when
`handler.establish_connection :primary` has never been called will
remove the connection for `ActiveRecord::Base` and throw a deprecation
warning.

See #38179 for details on more motivations for this change.

Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
2020-01-08 16:49:41 -05:00
..
associations Fuse traversals of the record set when preloading 2020-01-08 08:14:04 +13:00
attribute_methods [ci skip] Fix typo, will_save_change_to_attribute -> will_save_change_to_attribute? 2019-12-11 23:02:38 +09:00
coders Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
connection_adapters Deprecate "primary" as a connection_specification_name for ActiveRecord::Base 2020-01-08 16:49:41 -05:00
database_configurations Restore previous behavior of parallel test databases 2020-01-07 16:03:00 -05:00
fixture_set Fix an error message to replace http with https in a reference URL 2019-09-02 10:02:29 +09:00
locale
locking Don't parse DB specific locking docs as code 2019-11-12 16:04:58 +01:00
middleware Call while_preventing_writes from connected_to 2019-08-28 13:44:51 -04:00
migration Merge pull request #36589 from yskkin/reversible_remove_columns 2019-12-17 20:41:25 -03:00
railties remove reference to global rails command and replace with bin/rails 2019-12-27 19:32:37 +00:00
relation Merge pull request #38145 from sinsoku/avoid_assigning_the_same_value_to_join_values 2020-01-04 21:31:36 +09:00
scoping Improve deprecation message for leaking scope 2019-11-15 18:26:19 +09:00
tasks Use full option names in psql / pg_dump for clarity 2020-01-06 19:46:42 +03:00
type Registration#matches? takes keyword arguments 2019-09-07 11:51:20 +09:00
type_caster Fall back to type casting from the connection adapter 2019-05-21 23:41:13 +09:00
validations Add ActiveRecord::Validations::NumericalityValidator 2020-01-06 19:01:29 -05:00
aggregations.rb Fix docs to replace http with https in activerecord [ci skip] 2019-08-26 22:34:33 +09:00
association_relation.rb Refactor association.scoping not to rely on klass.all 2019-10-22 00:06:31 +09:00
associations.rb document the default for dependent activerecord option 2019-11-03 22:43:53 -08:00
attribute_assignment.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
attribute_decorators.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
attribute_methods.rb Simplify class_method_defined_within 2019-10-21 15:22:41 +09:00
attributes.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
autosave_association.rb Remove comment 2020-01-06 16:18:32 -05:00
base.rb Remove unused requires 2019-10-29 21:52:27 -04:00
callbacks.rb Unify AR touch method signatures 2019-09-06 18:52:00 +09:00
connection_adapters.rb Remove Resolver autoload 2019-11-13 15:28:50 -08:00
connection_handling.rb Deprecate "primary" as a connection_specification_name for ActiveRecord::Base 2020-01-08 16:49:41 -05:00
core.rb Make belongs_to_required_by_default a class attribute: 2019-12-17 19:17:58 +01:00
counter_cache.rb
database_configurations.rb Move name key on configuration hash into DatabaseConfig 2019-12-17 15:59:49 -05:00
define_callbacks.rb
dynamic_matchers.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
enum.rb Allow AR::Enum definitions with boolean values 2019-12-24 07:05:42 -10:00
errors.rb Update MySQL links to the current version of the manual [ci skip] 2019-10-03 20:22:29 -04:00
explain.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
explain_registry.rb
explain_subscriber.rb Use match? where we don't need MatchData 2019-07-27 13:06:49 +09:00
fixtures.rb remove reference to global rails command and replace with bin/rails 2019-12-27 19:32:37 +00:00
gem_version.rb Start Rails 6.1 development 2019-04-24 15:57:14 -04:00
inheritance.rb Add methods to the public API of ActiveRecord::Inheritance 2019-10-17 16:56:07 -04:00
insert_all.rb Merge pull request #37299 from kobsy/specify-pk-as-conflict-target 2020-01-05 10:09:48 -03:00
integration.rb Remove wrong default value for cache_versioning in documentation of cache_version 2019-05-29 11:47:45 +02:00
internal_metadata.rb t.string takes keyword arguments 2019-09-24 13:48:14 +09:00
legacy_yaml_adapter.rb
log_subscriber.rb Reduce object allocations during activerecord.sql logging 2019-08-18 23:58:13 +09:00
migration.rb remove reference to global rails command and replace with bin/rails 2019-12-27 19:32:37 +00:00
model_schema.rb Address all possible Performance/StartWith / Performance/EndWith violations 2019-11-14 03:20:29 +09:00
nested_attributes.rb [ci skip] switch eg. to proper e.g. 2019-10-07 02:18:36 +02:00
no_touching.rb Unify AR touch method signatures 2019-09-06 18:52:00 +09:00
null_relation.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
persistence.rb Add two cross links to methods in docs [skip ci] 2019-10-15 22:31:24 +10:00
query_cache.rb Reduce Array allocations 2019-07-31 17:41:34 +09:00
querying.rb Add missing touch_all delegation to relation 2019-04-05 16:13:40 +09:00
railtie.rb Enable Layout/ClosingHeredocIndentation cop 2019-11-24 09:44:32 +09:00
readonly_attributes.rb Extract readonly_attribute? 2019-05-27 06:41:31 +09:00
reflection.rb Bump RuboCop version to 0.77 2019-11-27 23:58:49 +00:00
relation.rb Merge pull request #38099 from alipman88/avoid_unecessary_query_if_cache_versioning_enabled 2020-01-06 08:52:41 -05:00
result.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
runtime_registry.rb
sanitization.rb [ci skip] switch eg. to proper e.g. 2019-10-07 02:18:36 +02:00
schema.rb Move SchemaMigration to migration_context 2019-06-14 11:15:08 -04:00
schema_dumper.rb remove reference to global rails command and replace with bin/rails 2019-12-27 19:32:37 +00:00
schema_migration.rb Fix keyword arguments warnings 2019-09-09 22:49:09 +09:00
scoping.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
secure_token.rb Set default of 28 characters in ActiveStorage::Blob.generate_unique_secure_token 2019-04-09 19:45:26 -04:00
serialization.rb Use try only when we're unsure if the receiver would respond_to the method 2019-08-01 17:58:00 +09:00
statement_cache.rb
store.rb [ci skip] switch eg. to proper e.g. 2019-10-07 02:18:36 +02:00
suppressor.rb AR save takes keyword arguments 2019-09-06 18:52:00 +09:00
table_metadata.rb Bump RuboCop version to 0.77 2019-11-27 23:58:49 +00:00
test_databases.rb Restore previous behavior of parallel test databases 2020-01-07 16:03:00 -05:00
test_fixtures.rb Merge pull request #37774 from Edouard-chin/ec-enlist-fixture-connection 2019-11-22 09:46:14 -05:00
timestamp.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
touch_later.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
transactions.rb Clear callback triggers when transaction completes 2019-12-27 01:33:22 +00:00
translation.rb
type.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
type_caster.rb
validations.rb Add ActiveRecord::Validations::NumericalityValidator 2020-01-06 19:01:29 -05:00
version.rb