You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
This is necessary because in PostgreSQL, `-` is a unary operator that
has lower precedence than the `::` operator, and that can cause problems
at the edge of allowed ranges.
For example, `-32768::int2` is parsed as `-(32768::int2)`, which throws
an "out of range" error, even though `(-32768)::int2` is accepted.
Closeshaskellari#143.
Postgresql parses
- <num> :: <type>
as- (<num> :: <type>)
. That can cause problems when trying to reference a type's minimum value:In the context of postgresql-simple, we can get problems if we try to do e.g.
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:
The text was updated successfully, but these errors were encountered: