From 926c584dcd7ef32d8c7e8753507cc0ea32a77bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Wed, 29 Nov 2023 19:43:48 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=94=87=20Do=20not=20raise=20deprecati?= =?UTF-8?q?on=20warnings=20for=20execute=20as=20it's=20automatically=20use?= =?UTF-8?q?d=20internally?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sqlmodel/orm/session.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sqlmodel/orm/session.py b/sqlmodel/orm/session.py index 6050d5fbc1..e404bb137d 100644 --- a/sqlmodel/orm/session.py +++ b/sqlmodel/orm/session.py @@ -95,7 +95,8 @@ def exec( ```Python heroes = session.exec(select(Hero)).all() ``` - """ + """, + category=None, ) def execute( # type: ignore self, From 4a7664f41a480097abc6d091d5312ea662e85e50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Wed, 29 Nov 2023 19:44:15 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=85=20Tweak=20tests=20to=20not=20use?= =?UTF-8?q?=20deprecated=20query?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 72465cda33..bdbcdeb76d 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -3,7 +3,7 @@ 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 @@ class Hero(SQLModel, table=True): 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 @@ class Hero(SQLModel, table=True): 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