jsonb numerics are treated as arrays
От | Leo Gaspard |
---|---|
Тема | jsonb numerics are treated as arrays |
Дата | |
Msg-id | 87h6jbbxma.fsf@coegni.ekleog.org обсуждение исходный текст |
Список | pgsql-bugs |
Hey! A short transcript is better than a thousand words: on PostgreSQL 16.1, I'm getting: ``` postgres=> SELECT ('42'::jsonb)->0, ('42'::jsonb)->(-1); ?column? | ?column? ----------+---------- 42 | 42 (1 row) ``` Dereferencing them with `1` or `-2` returns null as expected, indicating that jsonb numerics are currently being handled as one-element arrays. Considering the documentation[1] and especially the note there, I'd have expected numerics dereferencing to result in `NULL`, because they are not actually arrays. [1] https://www.postgresql.org/docs/current/functions-json.html#FUNCTIONS-JSON-PROCESSING TBH, considering this behavior has been present since PostgreSQL 14 at least, I'd guess it's probably something that can no longer change and will need to just be documented as being the current behavior. But I still wanted to raise this on the bugs mailing list, before sending it to the docs mailing list, because maybe it's behavior that could still be subject to change? I'll let you do as you wish, and will work around the issue myself by checking for jsonb_typeof before dereferencing with 0 or -1 :) Anyway, thank you for all you do on postgresql, it's a real pleasure to use! :D Léo PS: FWIW, this issue was discovered by the fuzzers for my library when I left them running overnight, comparing the postgresql backend with a "completely in-memory" equivalent model.
В списке pgsql-bugs по дате отправления: