chore: upgrade SQLAlchemy to 1.4 (#19890)

* chore: upgrade SQLAlchemy

* Convert integration test to unit test

* Fix SQLite

* Update method names/docstrings

* Skip test

* Fix SQLite
This commit is contained in:
Beto Dealmeida
2022-07-18 15:21:38 -07:00
committed by GitHub
parent 90600d1883
commit e60083b45b
32 changed files with 656 additions and 255 deletions

View File

@@ -117,7 +117,9 @@ builtin_time_grains: Dict[Optional[str], str] = {
}
class TimestampExpression(ColumnClause): # pylint: disable=abstract-method
class TimestampExpression(
ColumnClause
): # pylint: disable=abstract-method, too-many-ancestors
def __init__(self, expr: str, col: ColumnClause, **kwargs: Any) -> None:
"""Sqlalchemy class that can be can be used to render native column elements
respeting engine-specific quoting rules as part of a string-based expression.
@@ -933,9 +935,13 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
]
@classmethod
def adjust_database_uri(cls, uri: URL, selected_schema: Optional[str]) -> None:
def adjust_database_uri( # pylint: disable=unused-argument
cls,
uri: URL,
selected_schema: Optional[str],
) -> URL:
"""
Mutate the database component of the SQLAlchemy URI.
Return a modified URL with a new database component.
The URI here represents the URI as entered when saving the database,
``selected_schema`` is the schema currently active presumably in
@@ -949,9 +955,10 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
For those it's probably better to not alter the database
component of the URI with the schema name, it won't work.
Some database drivers like presto accept '{catalog}/{schema}' in
Some database drivers like Presto accept '{catalog}/{schema}' in
the database component of the URL, that can be handled here.
"""
return uri
@classmethod
def patch(cls) -> None:
@@ -1206,17 +1213,20 @@ class BaseEngineSpec: # pylint: disable=too-many-public-methods
return costs
@classmethod
def modify_url_for_impersonation(
def get_url_for_impersonation(
cls, url: URL, impersonate_user: bool, username: Optional[str]
) -> None:
) -> URL:
"""
Modify the SQL Alchemy URL object with the user to impersonate if applicable.
Return a modified URL with the username set.
:param url: SQLAlchemy URL object
:param impersonate_user: Flag indicating if impersonation is enabled
:param username: Effective username
"""
if impersonate_user and username is not None:
url.username = username
url = url.set(username=username)
return url
@classmethod
def update_impersonation_config(