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 bfec23aecb Fix PG::ConnectionBad error when running fixtures
At first this appeared to be a multi-db bug but after some invesitgation
it was clear that this can occur just by calling `establish_connection`
from ApplicationRecord.

After some investigation we found that this only occurred when using
fixtures. The console boots fine, the server runs fine, and the tests
even run fine if we used paralellization or eager loading in the tests.

I tracked the issue down to the line that calls
`self.connection_specification_name = name` in the SchemaMigration
changes for Rails 6.0. But how can this be? That is not that major of a
change? How could `connection_specification_name` be a problem?

First `connection_specification_name` caches the name of the connection
specificatio. Second, fixtures were incorrectly holding onto a reference
to that connection.

So when you went to run the tests the models wouldn't be connected and
when the fixtures tried to load the data it would choke on that
unconnected database.

The changes here move the connection into a lambda so we can call it
when we need it rather than blowing up before the model is connected.

Fixes #36743

Co-authored-by: Aaron Patterson <aaron.patterson@gmail.com>
2019-08-02 15:22:11 -04:00
..
associations Use try only when we're unsure if the receiver would respond_to the method 2019-08-01 17:58:00 +09:00
attribute_methods It may be better to explicitly require 'object/try' where we call try 2019-08-01 18:51:51 +09:00
coders Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
connection_adapters Add ability to unset preventing writes 2019-08-02 12:10:32 -04:00
database_configurations Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
fixture_set Allow specify fixtures to be ignored 2019-07-27 16:40:16 +08:00
locale
locking Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
middleware Add ability to unset preventing writes 2019-08-02 12:10:32 -04:00
migration Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
railties Fix db:seed 2019-07-31 12:22:01 -04:00
relation Deduplicate joins values 2019-08-02 03:35:44 +09:00
scoping Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
tasks Move DatabaseAlreadyExists detection to DB adapter 2019-07-29 08:40:57 -07:00
type Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
type_caster Fall back to type casting from the connection adapter 2019-05-21 23:41:13 +09:00
validations Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
aggregations.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
association_relation.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
associations.rb Improve doc of automatic inverse_of detection 2019-03-08 09:50:45 +01: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 Allow quoted identifier string as safe SQL string 2019-06-06 03:57:24 +09:00
attributes.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
autosave_association.rb Don't validate non dirty association targets 2019-07-15 18:21:20 +01:00
base.rb active_support/core_ext/object/duplicable is not in use here 2019-07-16 05:05:28 +09:00
callbacks.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
connection_handling.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
core.rb Fixed a typo in documentation example of activerecord database configuration. [ci skip] 2019-08-01 07:23:51 +05:30
counter_cache.rb
database_configurations.rb Introduce InvalidConfigurationError 2019-08-01 16:33:58 -04:00
define_callbacks.rb
dynamic_matchers.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
enum.rb Add a warning for enum elements with 'not_' prefix. 2019-06-30 15:21:30 -03:00
errors.rb Use try only when we're unsure if the receiver would respond_to the method 2019-08-01 17:58:00 +09: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 Fix PG::ConnectionBad error when running fixtures 2019-08-02 15:22:11 -04:00
gem_version.rb Start Rails 6.1 development 2019-04-24 15:57:14 -04:00
inheritance.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
insert_all.rb Avoid new string instance creation in InsertAll#execute 2019-04-22 23:12:23 +09: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 Remove duplicated table_exists? 2019-06-13 13:52:07 +09:00
legacy_yaml_adapter.rb
log_subscriber.rb Find query_source_location using lazy Enumerator 2019-04-15 16:13:06 -07:00
migration.rb Revert schema dumper to use strings rather than integers 2019-06-20 14:00:42 +02:00
model_schema.rb Better error message for calling columns_hash 2019-06-19 14:23:03 -04:00
nested_attributes.rb No Woman, No try 2019-07-12 18:32:45 +09:00
no_touching.rb
null_relation.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
persistence.rb Accessing ivar with Symbols might be just a very little bit better than with fstrings 2019-07-31 12:18:44 +09: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 It may be better to explicitly require 'object/try' where we call try 2019-08-01 18:51:51 +09:00
readonly_attributes.rb Extract readonly_attribute? 2019-05-27 06:41:31 +09:00
reflection.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
relation.rb document update_counters on relation [ci skip] 2019-05-11 14:13:32 -04:00
result.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
runtime_registry.rb
sanitization.rb Refactor disallow_raw_sql! to avoid split(/\s*,\s*/) to order args 2019-06-09 14:14:10 +09:00
schema.rb Move SchemaMigration to migration_context 2019-06-14 11:15:08 -04:00
schema_dumper.rb MySQL: Fix schema dumping enum and set columns correctly 2019-07-05 18:42:41 +09:00
schema_migration.rb Revert schema dumper to use strings rather than integers 2019-06-20 14:00:42 +02:00
scoping.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
secure_token.rb
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 Ruby 2.7 warning: creating a Proc without a block 2019-02-13 02:11:21 +01:00
store.rb Add saved changes helpers for store accessors 2019-03-25 18:53:07 -04:00
suppressor.rb
table_metadata.rb Fall back to type casting from the connection adapter 2019-05-21 23:41:13 +09:00
test_databases.rb
test_fixtures.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09: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 Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
translation.rb
type.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
type_caster.rb
validations.rb Enable Layout/EmptyLinesAroundAccessModifier cop 2019-06-13 12:00:45 +09:00
version.rb