mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #26219 -- Fixed crash when filtering by Decimal in RawQuery.
This commit is contained in:
parent
88034c9938
commit
fdccc02576
4 changed files with 11 additions and 1 deletions
|
@ -29,6 +29,7 @@ class BookFkAsPk(models.Model):
|
|||
|
||||
class Coffee(models.Model):
|
||||
brand = models.CharField(max_length=255, db_column="name")
|
||||
price = models.DecimalField(max_digits=10, decimal_places=2, default=0)
|
||||
|
||||
|
||||
class Reviewer(models.Model):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
from django.db.models.query_utils import InvalidQuery
|
||||
from django.test import TestCase, skipUnlessDBFeature
|
||||
|
@ -307,3 +308,8 @@ class RawQueryTests(TestCase):
|
|||
"""
|
||||
b = BookFkAsPk.objects.create(book=self.b1)
|
||||
self.assertEqual(list(BookFkAsPk.objects.raw('SELECT not_the_default FROM raw_query_bookfkaspk')), [b])
|
||||
|
||||
def test_decimal_parameter(self):
|
||||
c = Coffee.objects.create(brand='starbucks', price=20.5)
|
||||
qs = Coffee.objects.raw("SELECT * FROM raw_query_coffee WHERE price >= %s", params=[Decimal(20)])
|
||||
self.assertEqual(list(qs), [c])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue