Skip to content

Commit

Permalink
Merge pull request #488 from davvid/sqlalchemy
Browse files Browse the repository at this point in the history
* davvid/sqlalchemy:
  sqlalchemy: update sqlalchemy.orm.declarative_base usage
  • Loading branch information
davvid committed Apr 9, 2024
2 parents 4eb8869 + 25c9953 commit f422d79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -5,6 +5,7 @@ v3.0.4
* The test suite was made compatible with `pytest-ruff>=0.3.0`. (+482)
* A `garden.yaml` file was added for use with the
`garden <https://crates.io/crates/garden-tools>_` command runner. (+486)
* The test suite was updated to avoid deprecated SQLALchemy APIs.

v3.0.3
======
Expand Down
8 changes: 7 additions & 1 deletion tests/sqlalchemy_test.py
Expand Up @@ -8,6 +8,7 @@

try:
import sqlalchemy as sqa
from sqlalchemy import orm
from sqlalchemy.ext import declarative
from sqlalchemy.orm import Session

Expand All @@ -16,7 +17,12 @@
HAS_SQA = False

if HAS_SQA:
Base = declarative.declarative_base()
# sqlalchemy.ext.declarative.declarative_base() was deprecated in SQLAlchemy 2.0
# and replaced by sqlalchemy.orm.declarative_base().
if hasattr(orm, 'declarative_base'):
Base = orm.declarative_base()
else:
Base = declarative.declarative_base()

class Table(Base):
__tablename__ = 'table'
Expand Down

0 comments on commit f422d79

Please sign in to comment.