Skip to content

Conversation

koic
Copy link
Collaborator

@koic koic commented Jul 24, 2019

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.
#1900

Other Information

The following is an implementation example I gave up.

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.

### 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.
@yahonda
Copy link
Collaborator

yahonda commented Jul 24, 2019

As discussed at Asakusa.rb, I wanted Oracle enhanced adapter have own self.database_exists? method to leave some comments and rererence to #1900 .

@yahonda yahonda merged commit 8971181 into rsim:master Jul 24, 2019
@koic koic deleted the add_database_exist_method branch July 24, 2019 01:32
@koic
Copy link
Collaborator Author

koic commented Jul 24, 2019

Thank you for the supplementary explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants