Skip to content

Commit 718a89e

Browse files
committed
add none query feature and test for the same
1 parent 2db4699 commit 718a89e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

django_async_orm/query.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ async def async_latest(self, *fields):
4242
async def async_first(self):
4343
return await sync_to_async(self.first, thread_sensitive=True)()
4444

45+
async def async_none(self):
46+
return await sync_to_async(self.none, thread_sensitive=True)()
47+
4548
async def async_last(self):
4649
return await sync_to_async(self.last, thread_sensitive=True)()
4750

tests/test_django_async_orm.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from django.conf import settings
66
from django.apps import apps
77
from unittest import IsolatedAsyncioTestCase
8+
from django.db.models.query import EmptyQuerySet
89
import time
910

1011
from .models import TestModel
@@ -135,6 +136,11 @@ async def test_async_count(self):
135136
result = await TestModel.objects.async_all()
136137
self.assertEqual(result.count(), 1)
137138

139+
@tag('ci')
140+
async def test_async_none(self):
141+
result = await TestModel.objects.none()
142+
self.assertEqual(result, EmptyQuerySet)
143+
138144
@tag('ci')
139145
async def test_async_aiter(self):
140146
all_qs = await TestModel.objects.async_all()

0 commit comments

Comments
 (0)