Skip to content

Commit

Permalink
fix: support sqlalchemy 1.3.18 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
machow committed May 31, 2022
1 parent 507bb98 commit 5aaa935
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions siuba/sql/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ def mock_sqlalchemy_engine(dialect):
"""

from sqlalchemy.engine import Engine, URL
from sqlalchemy.engine import Engine
from sqlalchemy.dialects import registry
from types import ModuleType

# TODO: can be removed once v1.3.18 support dropped
from sqlalchemy.engine.url import URL


dialect_cls = registry.load(dialect)

# there is probably a better way to do this, but for some reason duckdb
Expand All @@ -59,7 +63,15 @@ def mock_sqlalchemy_engine(dialect):
dialect_cls = dialect_cls.dialect

conn = MockConnection(dialect_cls(), lambda *args, **kwargs: None)
conn.url = URL.create(drivername=dialect)

# set a url on it, so that LazyTbl can read the backend name.
if is_sqla_12() or is_sqla_13():
url = URL(drivername=dialect)
else:
url = URL.create(drivername=dialect)

conn.url = url

return conn


Expand Down

0 comments on commit 5aaa935

Please sign in to comment.