You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/08/23 22:38:41 UTC

[GitHub] [superset] eschutho commented on a diff in pull request #21171: [WIP] fix: improve get_db_engine_spec_for_backend

eschutho commented on code in PR #21171:
URL: https://github.com/apache/superset/pull/21171#discussion_r953165184


##########
superset/models/core.py:
##########
@@ -635,15 +635,25 @@ def get_all_schema_names(  # pylint: disable=unused-argument
 
     @property
     def db_engine_spec(self) -> Type[db_engine_specs.BaseEngineSpec]:
-        return self.get_db_engine_spec_for_backend(self.backend)
+        sqlalchemy_url = make_url_safe(self.sqlalchemy_uri_decrypted)
+        backend = sqlalchemy_url.get_backend_name()
+        driver = sqlalchemy_url.get_driver_name()
+
+        return self.get_db_engine_spec(backend, driver)
 
     @classmethod
     @memoized
-    def get_db_engine_spec_for_backend(
-        cls, backend: str
+    def get_db_engine_spec(
+        cls,
+        backend: str,
+        driver: str,
     ) -> Type[db_engine_specs.BaseEngineSpec]:
         engines = db_engine_specs.get_engine_specs()
-        return engines.get(backend, db_engine_specs.BaseEngineSpec)
+        for engine in engines.values():
+            if engine.engine == backend and engine.driver == driver:
+                return engine
+
+        raise Exception("No engine found")

Review Comment:
   For backward compatibility of connections that aren't using a "supported" driver, should we default to just a matching engine name if no engine+driver combo is found instead of raising an error?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org