#31723: Lag() with DecimalField crashes on SQLite.
-------------------------------------+-------------------------------------
     Reporter:  qwango               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  3.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  Lag                  |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 Likely an issue due to `SQLiteNumericMixin`
 
https://github.com/django/django/blob/27c09043da52ca1f02605bf28600bfd5ace95ae4/django/db/models/expressions.py#L16-L28

 We could make `Window` inherit from `SQLiteNumericMixin` and make
 `SQLiteNumericMixin.as_sqlite` a noop when `getattr(self,
 'window_compatible', False)`.

 An alternative would be to make `Window` inherit from `SQLiteNumericMixin`
 and make its `as_sqlite` special case itself when
 `isinstance(self.output_field, 'DecimalField')` with something along

 {{{#!python
 def as_sqlite(self, compiler, connection):
     if isinstance(self.output_field, 'DecimalField'):
         copy = self.copy()
         source_expressions = copy.get_source_expressions()
         source_expressions[0].output_field = FloatField()
         copy.set_source_expressions(source_expressions)
         return super(Window, copy).as_sqlite(compiler, connection)
     return self.as_sql(compiler, connection)
 }}}

 That would avoid teaching `SQLiteNumericMixin` about window functions and
 make sure window compatible functions can be used outside of windows
 expressions while being wrapped appropriately.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31723#comment:2>
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/064.3148a7d6e751bda19e09f89766784010%40djangoproject.com.

Reply via email to