mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #27481 -- Made SQLite return annotated boolean values as boolean, not integer.
Thanks Simon Charette for review.
This commit is contained in:
parent
967be82443
commit
c7bfcd2f37
2 changed files with 18 additions and 1 deletions
|
@ -6,7 +6,7 @@ from decimal import Decimal
|
|||
from django.core.exceptions import FieldDoesNotExist, FieldError
|
||||
from django.db.models import (
|
||||
BooleanField, CharField, Count, DateTimeField, ExpressionWrapper, F, Func,
|
||||
IntegerField, Q, Sum, Value,
|
||||
IntegerField, NullBooleanField, Q, Sum, Value,
|
||||
)
|
||||
from django.db.models.functions import Lower
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
|
@ -488,3 +488,15 @@ class NonAggregateAnnotationTestCase(TestCase):
|
|||
],
|
||||
lambda c: (c.name, c.tagline_lower)
|
||||
)
|
||||
|
||||
def test_boolean_value_annotation(self):
|
||||
books = Book.objects.annotate(
|
||||
is_book=Value(True, output_field=BooleanField()),
|
||||
is_pony=Value(False, output_field=BooleanField()),
|
||||
is_none=Value(None, output_field=NullBooleanField()),
|
||||
)
|
||||
self.assertGreater(len(books), 0)
|
||||
for book in books:
|
||||
self.assertIs(book.is_book, True)
|
||||
self.assertIs(book.is_pony, False)
|
||||
self.assertIsNone(book.is_none)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue