Skip to content

Commit

Permalink
Fix engine validation
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida committed Aug 28, 2022
1 parent 3f75b7b commit c9f6b4a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions superset/databases/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def sqlalchemy_uri_validator(value: str) -> str:
[
_(
"Invalid connection string, a valid string usually follows: "
"driver://user:password@database-host/database-name"
"backend+driver://user:password@database-host/database-name"
)
]
) from ex
Expand Down Expand Up @@ -263,19 +263,19 @@ def build_sqlalchemy_uri(
or parameters.pop("engine", None)
or data.pop("backend", None)
)
if not engine:
raise ValidationError(
[
_(
"An engine must be specified when passing "
"individual parameters to a database."
)
]
)
driver = data.pop("driver", None)

configuration_method = data.get("configuration_method")
if configuration_method == ConfigurationMethod.DYNAMIC_FORM:
if not engine:
raise ValidationError(
[
_(
"An engine must be specified when passing "
"individual parameters to a database."
)
]
)
engine_spec = get_engine_spec(engine, driver)

if not hasattr(engine_spec, "build_sqlalchemy_uri") or not hasattr(
Expand Down
2 changes: 1 addition & 1 deletion superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def get_db_engine_spec(cls, url: URL) -> Type[db_engine_specs.BaseEngineSpec]:
driver = url.get_driver_name()
except NoSuchModuleError:
# can't load the driver, fallback for backwards compatibility
return db_engine_specs.BaseEngineSpec
driver = None

return db_engine_specs.get_engine_spec(backend, driver)

Expand Down

0 comments on commit c9f6b4a

Please sign in to comment.