From 4ac87146b1dc7ffb0c5c8cc2e8c3744b9a5f940e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 30 Nov 2023 16:23:06 +0100 Subject: [PATCH] =?utf8?q?=F0=9F=94=87=20Do=20not=20raise=20deprecation=20?= =?utf8?q?warnings=20for=20execute=20as=20it's=20automatically=20used=20in?= =?utf8?q?ternally=20(#716)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * 🔇 Do not raise deprecation warnings for execute as it's automatically used internally * ✅ Tweak tests to not use deprecated query --- sqlmodel/orm/session.py | 3 ++- tests/test_main.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/sqlmodel/orm/session.py b/sqlmodel/orm/session.py index 6050d5fb..e404bb13 100644 --- a/sqlmodel/orm/session.py +++ b/sqlmodel/orm/session.py @@ -95,7 +95,8 @@ class Session(_Session): ```Python heroes = session.exec(select(Hero)).all() ``` - """ + """, + category=None, ) def execute( # type: ignore self, diff --git a/tests/test_main.py b/tests/test_main.py index 72465cda..bdbcdeb7 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -3,7 +3,7 @@ from typing import List, Optional import pytest from sqlalchemy.exc import IntegrityError from sqlalchemy.orm import RelationshipProperty -from sqlmodel import Field, Relationship, Session, SQLModel, create_engine +from sqlmodel import Field, Relationship, Session, SQLModel, create_engine, select def test_should_allow_duplicate_row_if_unique_constraint_is_not_passed(clear_sqlmodel): @@ -31,7 +31,7 @@ def test_should_allow_duplicate_row_if_unique_constraint_is_not_passed(clear_sql session.refresh(hero_2) with Session(engine) as session: - heroes = session.query(Hero).all() + heroes = session.exec(select(Hero)).all() assert len(heroes) == 2 assert heroes[0].name == heroes[1].name @@ -61,7 +61,7 @@ def test_should_allow_duplicate_row_if_unique_constraint_is_false(clear_sqlmodel session.refresh(hero_2) with Session(engine) as session: - heroes = session.query(Hero).all() + heroes = session.exec(select(Hero)).all() assert len(heroes) == 2 assert heroes[0].name == heroes[1].name -- 2.47.2