Missed key access should return null instead of error
alx3apps opened this issue · 0 comments
alx3apps commented
This example should return NULL
instead of throwing error:
select json_get_text('{"foo":"qq", "bar": true}', 'foo1');
ERROR: cannot extract from "{"foo":"qq", "bar": true}" json object by the key "foo1"
****** Error **********
ERROR: cannot extract from "{"foo":"qq", "bar": true}" json object by the key "foo1"
SQL state: 428094
It's necessary for LIKE
requests over JSON column with different structure.
It's debatable whether returning NULL
anywhere is sane practice (I think not), but here it's not possible for SQL requests to handle this error.
Also, functions already declared as return null on null input
(for performance reasons).
Also, legacy java implementation returns nulls on missed keys
reported by grey