#33257: Comparisons against DecimalField annotations behave inconsistently on
sqlite
-------------------------------------+-------------------------------------
     Reporter:  Matthijs Kooijman    |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Matthijs Kooijman):

 It seems that adding SQLiteNumericMixin to Case and ExpressionWrapper
 actually fixes this, with the below patch all my testcases pass:

 {{{diff
 --- a/django/db/models/expressions.py
 +++ b/django/db/models/expressions.py
 @@ -933,7 +933,7 @@ def as_sqlite(self, compiler, connection,
 **extra_context):
          return self.as_sql(compiler, connection, **extra_context)


 -class ExpressionWrapper(Expression):
 +class ExpressionWrapper(SQLiteNumericMixin, Expression):
      """
      An expression that can wrap another expression so that it can provide
      extra context to the inner expression, such as the output_field.
 @@ -1032,7 +1032,7 @@ def get_group_by_cols(self, alias=None):
          return cols


 -class Case(Expression):
 +class Case(SQLiteNumericMixin, Expression):
      """
      An SQL searched CASE expression:

 }}}

 I wonder if this mixing should be added to all expressions, so maybe to
 Expression or BaseExpression? I quickly tried, but got
 `django.db.utils.OperationalError: near "WHEN": syntax error` though.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33257#comment:1>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/074.3683bede08c4010765db595faa76ccdc%40djangoproject.com.

Reply via email to