Skip to content

Commit

Permalink
Upgrade to SQLAlchemy 2.0 (#16)
Browse files Browse the repository at this point in the history
* [change] sqla to 2.0 and update tests

* [change] bump ver

* [remove] appease mypy
  • Loading branch information
duynguyen158 authored Nov 28, 2023
1 parent 4473c8f commit bf7ad76
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 113 deletions.
2 changes: 1 addition & 1 deletion article_rec_db/models/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Article(SQLModel, UpdateTracked, table=True):
)


@event.listens_for(Article, "before_insert") # type: ignore
@event.listens_for(Article, "before_insert")
def validate_page_is_not_excluded(mapper: Any, connection: Any, target: Article) -> None:
# If page is none, the foreign key constraint will throw; see the test_article_without_page test
if target.page is not None:
Expand Down
4 changes: 2 additions & 2 deletions article_rec_db/models/recommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Recommendation(SQLModel, AutoUUIDPrimaryKey, CreationTracked, table=True):
)


@event.listens_for(Recommendation, "before_insert") # type: ignore
@event.listens_for(Recommendation, "before_insert")
def validate_source_id_lower_then_target_id_when_interchangeable(
mapper: Any, connection: Any, target: Recommendation
) -> None:
Expand All @@ -73,7 +73,7 @@ def validate_source_id_lower_then_target_id_when_interchangeable(
)


@event.listens_for(Recommendation, "before_insert") # type: ignore
@event.listens_for(Recommendation, "before_insert")
def validate_source_id_empty_when_strategy_default(mapper: Any, connection: Any, target: Recommendation) -> None:
if target.execution.strategy_recommendation_type == StrategyRecommendationType.DEFAULT_AKA_NO_SOURCE:
assert (
Expand Down
Loading

0 comments on commit bf7ad76

Please sign in to comment.