Fix Limit 0 QuerySet Empty List (#767)

* fix: debug condition check not none limit count

* test: write a test for check zero limit empty list

* fix: debug assert check empty list with is keyword
This commit is contained in:
Sepehr Bazyar
2022-07-29 19:53:10 +04:30
committed by GitHub
parent 8450c90420
commit e923513681
3 changed files with 16 additions and 2 deletions

View File

@ -47,6 +47,18 @@ def create_test_database():
metadata.drop_all(engine)
@pytest.mark.asyncio
async def test_limit_zero():
async with database:
async with database.transaction(force_rollback=True):
for i in range(5):
await Car(name=f"{i}").save()
cars = await Car.objects.limit(0).all()
assert cars == []
assert len(cars) == 0
@pytest.mark.asyncio
async def test_pagination_errors():
async with database: