#31956: QuerySet.order_by() chained with values() crashes on JSONField with a
custom decoder on PostgreSQL.
-------------------------------------+-------------------------------------
     Reporter:  Marc DEBUREAUX       |                    Owner:  felixxm
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * status:  new => assigned
 * severity:  Normal => Release blocker
 * cc: sage, Simon Charette (added)
 * owner:  nobody => felixxm
 * stage:  Unreviewed => Accepted


Comment:

 Thanks for this ticket. I was able to reproduce the crash on PostgreSQL
 with a `JSONField` with a custom decoder. It's caused by
 
[https://github.com/django/django/blob/e39e727ded673e74016b5d3658d23cbe20234d11/django/db/models/fields/json.py#L94-L100
 the different format] used in this case. Can you confirm that the
 following patch fix this issue for you?
 {{{
 diff --git a/django/db/models/expressions.py
 b/django/db/models/expressions.py
 index a9768919a2..af0419356a 100644
 --- a/django/db/models/expressions.py
 +++ b/django/db/models/expressions.py
 @@ -1211,6 +1211,7 @@ class OrderBy(BaseExpression):
                  template = '%%(expression)s IS NOT NULL, %s' % template
          connection.ops.check_expression_support(self)
          expression_sql, params = compiler.compile(self.expression)
 +        expression_sql, params = self.expression.select_format(compiler,
 expression_sql, params)
          placeholders = {
              'expression': expression_sql,
              'ordering': 'DESC' if self.descending else 'ASC',
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31956#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.d6c9a7a772181092bc03236002840724%40djangoproject.com.

Reply via email to