Fix collerek/ormar#588 Bug in queryset count() method

This commit is contained in:
haydeec1
2022-03-09 17:06:54 -05:00
parent 989e11e066
commit a7e78bbf8c
2 changed files with 16 additions and 1 deletions

View File

@ -175,3 +175,15 @@ async def test_queryset_method():
assert await author.books.max(["year", "title"]) == dict(
year=1930, title="Book 3"
)
@pytest.mark.asyncio
async def test_count_method():
async with database:
await sample_data()
count = await Author.objects.select_related("books").count()
assert count == 1
# The legacy functionality
count = await Author.objects.select_related("books").count(distinct=False)
assert count == 3