This is an automated email from the ASF dual-hosted git repository.

hugh pushed a commit to branch test-ssh-tunnel-1
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 0136ba3d1b801d0aaa09facce41d25c73ccd61ab
Author: Antonio Rivero <[email protected]>
AuthorDate: Mon Nov 28 10:36:20 2022 -0300

    SSH Tunnel:
    
    - Fix pre-commit errors
---
 superset/databases/commands/create.py | 4 ++--
 superset/databases/commands/update.py | 6 +++---
 superset/databases/dao.py             | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/superset/databases/commands/create.py 
b/superset/databases/commands/create.py
index ad8fa3a450..ef2f555d61 100644
--- a/superset/databases/commands/create.py
+++ b/superset/databases/commands/create.py
@@ -79,10 +79,10 @@ class CreateDatabaseCommand(BaseCommand):
                     "schema_access", 
security_manager.get_schema_perm(database, schema)
                 )
 
-            if self._properties.get("ssh_tunnel"):
+            if ssh_tunnel_properties := self._properties.get("ssh_tunnel"):
                 SSHTunnelDAO.create(
                     {
-                        **self._properties.get("ssh_tunnel"),
+                        **ssh_tunnel_properties,
                         "database_id": database.id,
                     },
                     commit=False,
diff --git a/superset/databases/commands/update.py 
b/superset/databases/commands/update.py
index b662ab3546..ba353b8960 100644
--- a/superset/databases/commands/update.py
+++ b/superset/databases/commands/update.py
@@ -96,13 +96,13 @@ class UpdateDatabaseCommand(BaseCommand):
                     "schema_access", 
security_manager.get_schema_perm(database, schema)
                 )
 
-            if self._properties.get("ssh_tunnel"):
+            if ssh_tunnel_properties := self._properties.get("ssh_tunnel"):
                 existing_ssh_tunnel = DatabaseDAO.get_ssh_tunnel(database.id)
                 if existing_ssh_tunnel is None:
                     # We couldn't found an existing tunnel so we need to 
create one
                     SSHTunnelDAO.create(
                         {
-                            **self._properties.get("ssh_tunnel"),
+                            **ssh_tunnel_properties,
                             "database_id": database.id,
                         },
                         commit=False,
@@ -112,7 +112,7 @@ class UpdateDatabaseCommand(BaseCommand):
                     ssh_tunnel_model = 
SSHTunnelDAO.find_by_id(existing_ssh_tunnel.id)
                     SSHTunnelDAO.update(
                         ssh_tunnel_model,
-                        self._properties.get("ssh_tunnel"),
+                        ssh_tunnel_properties,
                         commit=False,
                     )
 
diff --git a/superset/databases/dao.py b/superset/databases/dao.py
index 4e9ad1ee8c..d5a58245d1 100644
--- a/superset/databases/dao.py
+++ b/superset/databases/dao.py
@@ -127,7 +127,7 @@ class DatabaseDAO(BaseDAO):
         )
 
     @classmethod
-    def get_ssh_tunnel(cls, database_id: int) -> Dict[str, Any]:
+    def get_ssh_tunnel(cls, database_id: int) -> SSHTunnel:
         ssh_tunnel = (
             db.session.query(SSHTunnel)
             .filter(SSHTunnel.database_id == database_id)

Reply via email to