Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to SQLAlchemy 2.0 #16

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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