Skip to content
This repository was archived by the owner on Sep 4, 2025. It is now read-only.

Commit 50d577d

Browse files
fix: Ensure compatibility with SQLAlchemy 1 (#13)
* fix: Ensure compatibility with SQLAlchemy 1 * Fix types
1 parent 1db31d0 commit 50d577d

4 files changed

Lines changed: 18 additions & 5 deletions

File tree

.github/workflows/test.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ jobs:
4949
hatch run typing:check
5050
5151
test:
52-
name: Pytest
52+
name: Pytest (Python ${{ matrix.python-version }}, SQLAlchemy ${{ matrix.sqlalchemy-version }})
5353
runs-on: ubuntu-latest
5454
strategy:
5555
matrix:
5656
python-version: ["3.8", "3.9", "3.10", "3.11"]
57+
sqlalchemy-version: ["1", "2"]
5758
steps:
5859
- uses: actions/checkout@v3
5960
- uses: actions/setup-python@v4
@@ -66,6 +67,8 @@ jobs:
6667
run: |
6768
pipx install hatch
6869
- name: Run tests
70+
env:
71+
SQLALCHEMY_VERSION: ${{ matrix.sqlalchemy-version }}
6972
run: |
7073
hatch run test-cov
7174
- uses: actions/upload-artifact@v3

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Source = "https://github.com/edgarrmondragon/sqlean-driver"
4343
source = "vcs"
4444

4545
[tool.hatch.envs.default]
46-
dependencies = ["coverage[toml]>=6.5", "pytest"]
46+
dependencies = ["coverage[toml]>=6.5", "pytest", "sqlalchemy=={env:SQLALCHEMY_VERSION:1}.*"]
4747
[tool.hatch.envs.default.scripts]
4848
test = "pytest {args:tests}"
4949
test-cov = "coverage run -m pytest {args:tests}"

src/sqlean_driver/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class SQLeanDialect(SQLiteDialect_pysqlite):
2323
supports_statement_cache = True
2424

2525
@classmethod
26-
def import_dbapi(cls: type[SQLeanDialect]) -> ModuleType:
26+
def dbapi(cls: type[SQLeanDialect]) -> ModuleType: # type: ignore[override]
2727
"""Return the DBAPI module."""
2828
import sqlean
2929

@@ -35,8 +35,8 @@ def on_connect_url(self: SQLeanDialect, url: URL) -> t.Callable[[t.Any], t.Any]
3535
extensions = query if isinstance(query, tuple) else query.split(",")
3636

3737
if "all" in extensions:
38-
self.dbapi.extensions.enable_all() # type: ignore[union-attr]
38+
self.dbapi.extensions.enable_all() # type: ignore[attr-defined]
3939
else:
40-
self.dbapi.extensions.enable(*extensions) # type: ignore[union-attr]
40+
self.dbapi.extensions.enable(*extensions) # type: ignore[attr-defined]
4141

4242
return super().on_connect_url(url)

tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""Configuration for pytest."""
2+
3+
from __future__ import annotations
4+
5+
from sqlalchemy import __version__ as sqlalchemy_version
6+
7+
8+
def pytest_report_header() -> list[str]:
9+
"""Return a list of strings to be displayed in the header of the report."""
10+
return [f"sqlalchemy: {sqlalchemy_version}"]

0 commit comments

Comments
 (0)