﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28857	PostgreSQL Cast function shortcut	Jurica Železnjak	nobody	"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"	Bug	new	Database layer (models, ORM)	1.11	Normal		postgres,orm		Unreviewed	0	0	0	0	1	0
