-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make less than lookups exclude null values
- Loading branch information
Showing
5 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.db import models | ||
|
||
|
||
class Number(models.Model): | ||
num = models.IntegerField(blank=True, null=True) | ||
|
||
class Meta: | ||
ordering = ("num",) | ||
|
||
def __str__(self): | ||
return str(self.num) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from django.test import TestCase | ||
|
||
from .models import Number | ||
|
||
|
||
class NumericLookupTests(TestCase): | ||
@classmethod | ||
def setUpTestData(cls): | ||
cls.objs = Number.objects.bulk_create(Number(num=x) for x in range(5)) | ||
# Null values should be excluded in less than queries. | ||
Number.objects.create() | ||
|
||
def test_lt(self): | ||
self.assertQuerySetEqual(Number.objects.filter(num__lt=3), self.objs[:3]) | ||
|
||
def test_lte(self): | ||
self.assertQuerySetEqual(Number.objects.filter(num__lte=3), self.objs[:4]) |