#25507: Can't count when using annotate(field=RawSQL(sql)) when sql is a 
constant
-------------------------------------+-------------------------------------
     Reporter:  acatton              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Release blocker      |               Resolution:
     Keywords:  RawSQL filter ORM    |             Triage Stage:
  sql                                |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by akaariai):

 Who knew you can't group by a constant in PostgreSQL. Seems rather
 pointless limitation in my opinion, especially considering you can use
 functions that return a constant from the query's point of view (now(),
 txid_current, `'foo'||'bar'` etc).

 To fix this we need a way to tell Django a given value is a constant. For
 RawSQL the way would be to add a flag constant=True to the constructor.
 But this seems too complex.

 If we make sure you can use Value() annotations with group by, then we
 could just document that RawSQL with a constant value + aggregation do not
 work on PostgreSQL. Use Value() instead.

--
Ticket URL: <https://code.djangoproject.com/ticket/25507#comment:3>
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/065.c110579767a77f033607086f6445b3bd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to