This is an automated email from the ASF dual-hosted git repository.
villebro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 22d8171 chore(engine): adapt postgres backend connection URI (#11233)
22d8171 is described below
commit 22d8171dd68f0c054d8b0109ec63b65c55409cf0
Author: Yongjie Zhao <[email protected]>
AuthorDate: Wed Oct 14 23:57:41 2020 +0800
chore(engine): adapt postgres backend connection URI (#11233)
* chore(engine): adapt postgres backend connection URI
* fix tests
* Update superset/db_engine_specs/__init__.py
Co-authored-by: Ville Brofeldt <[email protected]>
Co-authored-by: Ville Brofeldt <[email protected]>
---
superset/db_engine_specs/__init__.py | 4 ++++
superset/db_engine_specs/base.py | 1 +
superset/db_engine_specs/postgres.py | 1 +
tests/db_engine_specs/postgres_tests.py | 7 +++++++
4 files changed, 13 insertions(+)
diff --git a/superset/db_engine_specs/__init__.py
b/superset/db_engine_specs/__init__.py
index 51408ae..df81966 100644
--- a/superset/db_engine_specs/__init__.py
+++ b/superset/db_engine_specs/__init__.py
@@ -49,3 +49,7 @@ for (_, name, _) in
pkgutil.iter_modules([Path(__file__).parent]): # type: igno
and attribute.engine != ""
):
engines[attribute.engine] = attribute
+
+ # populate engine alias name to engine dictionary
+ for engine_alias in attribute.engine_aliases or []:
+ engines[engine_alias] = attribute
diff --git a/superset/db_engine_specs/base.py b/superset/db_engine_specs/base.py
index 8456bb7..651b98f 100644
--- a/superset/db_engine_specs/base.py
+++ b/superset/db_engine_specs/base.py
@@ -137,6 +137,7 @@ class BaseEngineSpec: # pylint:
disable=too-many-public-methods
"""Abstract class for database engine specific configurations"""
engine = "base" # str as defined in sqlalchemy.engine.engine
+ engine_aliases: Optional[Tuple[str]] = None
engine_name: Optional[
str
] = None # used for user messages, overridden in child classes
diff --git a/superset/db_engine_specs/postgres.py
b/superset/db_engine_specs/postgres.py
index 4e673b2..d631231 100644
--- a/superset/db_engine_specs/postgres.py
+++ b/superset/db_engine_specs/postgres.py
@@ -67,6 +67,7 @@ class PostgresBaseEngineSpec(BaseEngineSpec):
class PostgresEngineSpec(PostgresBaseEngineSpec):
engine = "postgresql"
+ engine_aliases = ("postgres",)
max_column_name_length = 63
try_remove_schema_from_table_name = False
diff --git a/tests/db_engine_specs/postgres_tests.py
b/tests/db_engine_specs/postgres_tests.py
index 139b339..3f45f45 100644
--- a/tests/db_engine_specs/postgres_tests.py
+++ b/tests/db_engine_specs/postgres_tests.py
@@ -19,6 +19,7 @@ from unittest import mock
from sqlalchemy import column, literal_column
from sqlalchemy.dialects import postgresql
+from superset.db_engine_specs import engines
from superset.db_engine_specs.postgres import PostgresEngineSpec
from tests.db_engine_specs.base_tests import TestDbEngineSpec
@@ -117,3 +118,9 @@ class TestPostgresDbEngineSpec(TestDbEngineSpec):
cursor.description = []
results = PostgresEngineSpec.fetch_data(cursor, 1000)
self.assertEqual(results, [])
+
+ def test_engine_alias_name(self):
+ """
+ DB Eng Specs (postgres): Test "postgres" in engine spec
+ """
+ self.assertIn("postgres", engines)