mirror of https://github.com/apache/superset.git
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 <33317356+villebro@users.noreply.github.com> Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
This commit is contained in:
parent
5cbef88217
commit
22d8171dd6
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue