diff options
author | Jeremy Baker <jhubert@gmail.com> | 2016-02-04 01:32:45 -0800 |
---|---|---|
committer | Jeremy Baker <jhubert@gmail.com> | 2016-02-04 01:32:45 -0800 |
commit | 7429bc58a0dffa94636b21cc0cba1d19a5ae7a84 (patch) | |
tree | 57538ab8a1d933950d20d6f78343bbf5795be129 /ci | |
parent | dfa48f200cbc5c1ca18457a8cde14642e12af594 (diff) | |
download | rails-7429bc58a0dffa94636b21cc0cba1d19a5ae7a84.tar.gz rails-7429bc58a0dffa94636b21cc0cba1d19a5ae7a84.tar.bz2 rails-7429bc58a0dffa94636b21cc0cba1d19a5ae7a84.zip |
Remove the assumption of schema in DATABASE_URL
If you set the DATABASE_URL environment variable to `mydatabase` by accident, you end up getting a series of errors that are hard to trace. For example:
```
warning: already initialized constant ActiveRecord::Base::OrmAdapter
```
Turns out the cascade of errors is due to the error raised by `.tr` being called on `nil`.
This commit makes sure that `scheme` is set before calling `.tr` on it. My previous iteration used `@uri.scheme.try(:tr, '-', '_')` but using the `&&` logical operator is a fair bit faster: http://stackoverflow.com/questions/26655032/try-vs-performance
With this change, the error message becomes much more understandable:
```
FATAL: database "mydatabase" does not exist (ActiveRecord::NoDatabaseError)
```
Diffstat (limited to 'ci')
0 files changed, 0 insertions, 0 deletions