Open
Description
Postgresql parses - <num> :: <type>
as - (<num> :: <type>)
. That can cause problems when trying to reference a type's minimum value:
> select -2147483648 :: int4;
ERROR: integer out of range
> select (-2147483648) :: int4;
int4
-------------
-2147483648
In the context of postgresql-simple, we can get problems if we try to do e.g.
execute conn "INSERT INTO foo (col) VALUES (?::int4)" (Only someInt)
query conn "SELECT * FROM ?" (Values ["int4"] [Only someInt])
I think postgres has symmetric ranges for non-integer numbers, but since those can get cast to ints, it can still make a difference whether they're parenthesized:
> select -2147483648.2 :: int4;
ERROR: integer out of range
> select (-2147483648.2) :: int4;
int4
-------------
-2147483648
(1 row)