Thread: BUG #14935: Cast function shortcut gives an error

BUG #14935: Cast function shortcut gives an error

From
jzelez@gmail.com
Date:
The following bug has been logged on the website:

Bug reference:      14935
Logged by:          Jurica Železnjak
Email address:      jzelez@gmail.com
PostgreSQL version: 10.1
Operating system:   OS X
Description:

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"

ERROR message:
[22P02] ERROR: invalid input syntax for type double precision:
"{Temperature}"


Re: BUG #14935: Cast function shortcut gives an error

From
Marko Tiikkaja
Date:
On Wed, Nov 29, 2017 at 10:27 AM, wrote: > 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" > The precedence between the two is different. The equivalent would be: ("sensors_sensordata"."data" #>> '{Temperature}')::DOUBLE PRECISION In other words, not a bug. .m

Re: BUG #14935: Cast function shortcut gives an error

From
Jurica Železnjak
Date:
Ok. Thanks... I guess I should bring attention to this to the Django team where they use it without the parenthesis. Jurica > On Wednesday, Nov 29, 2017 at 10:52 AM, Marko Tiikkaja wrote: > On Wed, Nov 29, 2017 at 10:27 AM, wrote: > > 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" > > The precedence between the two is different. The equivalent would be: > > ("sensors_sensordata"."data" #>> '{Temperature}')::DOUBLE PRECISION > > In other words, not a bug. > > > .m