- changed status to invalid
Get Operators Need Higher Precedence
Issue #5
invalid
I think that the ->
and ->>
operators should have a very high precedence, so that they bind tightly to the JSON. Currently, this does not work:
try=# select '{"foo": 1}'::json ->> 'foo' = 1;
ERROR: operator does not exist: text = integer
LINE 1: select '{"foo": 1}'::json ->> 'foo' = 1;
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
I think it makes much more sense for ->>
to have a higher precedence than =
, so the output would be more like:
try=# select '{"foo": 1}'::json ->> 'foo' = 1;
?column?
----------
t
Thanks!
Comments (2)
-
-
reporter Funny, I forgot all about that. I'm repeating myself in my old age!
Pity one can't set precedence on operators, but I imagine it would be a lot of work to change the parser to do that, and might add too many cycles to the runtime to look up the precedence of every operator in an expression, eh?
- Log in to comment
The precendence of operators is defined in the grammar and not changeable (as Tom Lane told you last year, according to Google).
See http://www.postgresql.org/docs/9.2/static/sql-syntax-lexical.html#SQL-PRECEDENCE