pankajkoti commented on code in PR #31984:
URL: https://github.com/apache/airflow/pull/31984#discussion_r1233212735
##########
airflow/providers/microsoft/mssql/hooks/mssql.py:
##########
@@ -63,11 +63,10 @@ def connection_extra_lower(self) -> dict:
@property
def sqlalchemy_scheme(self) -> str:
"""Sqlalchemy scheme either from constructor, connection extras or
default."""
- return (
- self._sqlalchemy_scheme
- or self.connection_extra_lower.get("sqlalchemy_scheme")
- or self.DEFAULT_SQLALCHEMY_SCHEME
- )
+ extra_scheme = self.connection_extra_lower.get("sqlalchemy_scheme")
+ if not self._sqlalchemy_scheme and extra_scheme and (":" in
extra_scheme or "/" in extra_scheme):
+ raise RuntimeError("sqlalchemy_scheme in connection extra should
not contain : or / characters")
+ return self._sqlalchemy_scheme or extra_scheme or
self.DEFAULT_SQLALCHEMY_SCHEME
Review Comment:
What is the general precedence of considering connection parameters when
there are multiple ways to set a parameter?
I am under the impression that extras > constructor/hook params > default
##########
airflow/providers/microsoft/mssql/hooks/mssql.py:
##########
@@ -63,11 +63,10 @@ def connection_extra_lower(self) -> dict:
@property
def sqlalchemy_scheme(self) -> str:
"""Sqlalchemy scheme either from constructor, connection extras or
default."""
- return (
- self._sqlalchemy_scheme
- or self.connection_extra_lower.get("sqlalchemy_scheme")
- or self.DEFAULT_SQLALCHEMY_SCHEME
- )
+ extra_scheme = self.connection_extra_lower.get("sqlalchemy_scheme")
+ if not self._sqlalchemy_scheme and extra_scheme and (":" in
extra_scheme or "/" in extra_scheme):
Review Comment:
If the user has set `sqlalchemy_scheme` via constructor but wants to
override via extras, will we not allow it?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]