Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes when there isn't a database #87

Merged
merged 2 commits into from
Jan 11, 2022
Merged

Conversation

bliof
Copy link

@bliof bliof commented Apr 2, 2020

The lookup call tries to establish connection to the database when the application code is loading.

This bugs rake tasks like db:create / assets:precompile

def lookup(*args, adapter: current_adapter_name, **kwargs) # :nodoc:

The current_adapter_name for some reason does a db connection.

The code is change to getting the current adapter with ActiveRecord::Base.connection_config[:adapter], which is not making a db connection.

Replace update_attributes with update as update_attributes has been removed in rails 6

@bliof bliof added bug Something isn't working WIP labels Apr 2, 2020
@bliof bliof force-pushed the fix-rails-db-create branch from 7f95f8b to b7104a8 Compare April 2, 2020 14:29
@bliof-fc bliof-fc force-pushed the fix-rails-db-create branch 7 times, most recently from f746a0f to 7a05777 Compare January 11, 2022 12:31
When running db:create or assets:precompile the gem does a db connection
for no reason in rails 5.x. In rails 4 it is not doing it.

The bug happens here:

https://github.com/rails/rails/blob/v5.2.6/activerecord/lib/active_record/type.rb#L41

```
def lookup(*args, adapter: current_adapter_name, **kwargs) # :nodoc:
```

`current_adapter_name` for some reason does a db connection.
The lookup call tries to establish connection to the database when the application code is loading.

This bugs rake tasks like db:create / assets:precompile

https://github.com/rails/rails/blob/v5.2.6/activerecord/lib/active_record/type.rb#L41

```
def lookup(*args, adapter: current_adapter_name, **kwargs) # :nodoc:
```

The `current_adapter_name` for some reason does a db connection.

The code is change to getting the current adapter with `ActiveRecord::Base.connection_config[:adapter]`, which is not making a db connection.
@bliof-fc bliof-fc force-pushed the fix-rails-db-create branch from e054bdb to 006f61c Compare January 11, 2022 13:33
@bliof-fc bliof-fc removed the WIP label Jan 11, 2022
@bliof-fc bliof-fc merged commit 93bd3f2 into master Jan 11, 2022
@bliof-fc bliof-fc deleted the fix-rails-db-create branch January 11, 2022 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants