#28857: PostgreSQL Cast function shortcut
-------------------------------------+-------------------------------------
               Reporter:  jzelez     |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  1.11
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  postgres,orm
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  1
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 In some cases when using the shortcut notation "::" the database gives an
 error.

 GOOD:
   CAST("sensors_sensordata"."data" #>> '{Temperature}' AS DOUBLE
 PRECISION) AS "temp"

 ERROR:
   "sensors_sensordata"."data" #>> '{Temperature}'::DOUBLE PRECISION AS
 "temp"

 I've got a response from Postgre people and they've said:
 --------------
 The precedence between the two is different.  The equivalent would be:

   ("sensors_sensordata"."data" #>> '{Temperature}')::DOUBLE PRECISION

 In other words, not a bug.
 ------------

 So it seems the as_postgresql method needs to wrap the expression into
 parenthesis.
 
https://docs.djangoproject.com/en/1.11/_modules/django/db/models/functions/base/#Cast

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28857>
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/049.933eb2d476d2ee09045dff358a15ddb7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to