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
Raise NoDatabaseError
when db does not exist
#1900
Conversation
Follow up rails/rails#13469 and rails/rails#13427. This PR raises `NoDatabaseError` when db does not exist. `OCIError` was raised when database does not exist. This change uses `NoDatabaseError` as other core adapters.
Thanks for opening a pull request. From my point of view
|
@@ -73,6 +73,12 @@ def oracle_enhanced_connection(config) #:nodoc: | |||
ConnectionAdapters::OracleEnhancedAdapter.new( | |||
ConnectionAdapters::OracleEnhanced::Connection.create(config), logger, config) | |||
end | |||
rescue OCIError => error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. It should also support JDBC.
expected ActiveRecord::NoDatabaseError, got #<NameError: uninitialized constant ActiveRecord::ConnectionHandling::OCIError> with backtrace:
https://travis-ci.org/rsim/oracle-enhanced/jobs/556237777#L651
Let me have some more look at which error is appropriate to represent the database does not exist. |
Summary:From my point of view there is no good Oracle error message which represents Backgrounds:As far as I understand Unlike other mysql2 and postgresql adapters, Oracle enhanced adapter oracle-enhanced/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb Lines 15 to 29 in c0f24b4
Then Unfortunately this error message could be reported:
This error message can be used to raise |
### Summary Follow up rails/rails#36471. Oracle enhanced adapter has no implementation because Oracle Database cannot detect `NoDatabaseError`. Please refer to the following discussion for details. rsim#1900 ### Other Information The following is an implementation example I gave up. ```diff diff --git a/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb b/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb index af99718..77a5b90 100644 --- a/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +++ b/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb @@ -249,6 +249,12 @@ module ActiveRecord ADAPTER_NAME end + def self.database_exists?(config) + !!ActiveRecord::Base.oracle_enhanced_connection(config) + rescue ActiveRecord::NoDatabaseError + false + end + ``` This is an implementation example when `NoDatabaseError` can be supported in the future.
Thank you for your investigation. I opened this PR in preparation for PR #1906. However, I will close this PR because Oracle database cannot detect |
Follow up rails/rails#13469 and rails/rails#13427.
This PR raises
NoDatabaseError
when db does not exist.OCIError
was raised when database does not exist.This change uses
NoDatabaseError
as other core adapters.