Skip to content

Commit

Permalink
call select() directly from sqlalchemy instead of flask-sqlalchemy db…
Browse files Browse the repository at this point in the history
….select()
  • Loading branch information
jacquesfize committed Dec 15, 2023
1 parent 08363b2 commit 5311147
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/utils_flask_sqla/tests/test_qfilter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from flask import Flask
from sqlalchemy import func, and_
from sqlalchemy import func, and_, select

from flask_sqlalchemy import SQLAlchemy

Expand Down Expand Up @@ -61,21 +61,19 @@ class TestQfilter:
def test_qfilter(self, bar):
assert db.session.scalars(BarModel.where_pk_query(bar.pk)).one_or_none() is bar
assert (
db.session.scalars(db.select(BarModel).where(BarModel.where_pk(bar.pk))).one_or_none()
db.session.scalars(select(BarModel).where(BarModel.where_pk(bar.pk))).one_or_none()
is bar
)

assert db.session.scalars(BarModel.where_pk_query(bar.pk + 1)).one_or_none() is not bar
assert (
db.session.scalars(
db.select(BarModel).where(BarModel.where_pk(bar.pk + 1))
).one_or_none()
db.session.scalars(select(BarModel).where(BarModel.where_pk(bar.pk + 1))).one_or_none()
is not bar
)

assert (
db.session.scalars(
db.select(BarModel).where(BarModel.where_pk_list(bar.pk))
select(BarModel).where(BarModel.where_pk_list(bar.pk))
).one_or_none()
is bar
)

0 comments on commit 5311147

Please sign in to comment.