#26219: Cannot filter by DecimalField in RawQuery
----------------------------------------------+----------------------------
     Reporter:  jirek                         |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.9
     Severity:  Normal                        |   Keywords:  DecimalField
                                              |  RawQuery
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+----------------------------
 {{{
 #!python

 class Product(models.Model):
     name = models.CharField(max_length=128)
     price = models.DecimalField(max_digits=15, decimal_places=2,
 default=0, blank=True)

 products = Product.objects.raw(""" SELECT * FROM "products_product" WHERE
 price >= %s """, params=[Decimal(200), ])
 for product in products:
     print product
 }}}

 this will raise following exception
 {{{
 #!python

 File "site-packages\django\db\models\query.py", line 1219, in __iter__
     query = iter(self.query)
   File "site-packages\django\db\models\sql\query.py", line 79, in __iter__
     self._execute_query()
   File "site-packages\django\db\models\sql\query.py", line 106, in
 _execute_query
     params = tuple(adapter(val) for val in self.params)
   File "site-packages\django\db\models\sql\query.py", line 106, in
 <genexpr>
     params = tuple(adapter(val) for val in self.params)
   File "site-packages\django\db\backends\base\operations.py", line 455, in
 adapt_unknown_value
     return self.adapt_decimalfield_value(value)
 TypeError: adapt_decimalfield_value() takes exactly 4 arguments (2 given)
 }}}

 We are making much more complex query, this is just simple example of bug
 we are challenging

--
Ticket URL: <https://code.djangoproject.com/ticket/26219>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/048.ba8b0fef63905b1a0ef722453ee9acf7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to