Get Operators Need Higher Precedence

Issue #5 invalid
David Wheeler created an issue

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)

  1. David Wheeler 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?

  2. Log in to comment