Show json field name instead of ?column?
Thread notes
1 note#feature#minor#enhancement
hackorum-bot#feature#minor#enhancement
@global #feature #minor #enhancement
Hi Hackers,
While reviewing Json Simplified Accessor Support [1]/messages/by-id/CAK98qZ1JNNAx4QneJG+eX7iLesOhd6A68FNQVvvHP6Up_THf3A@mail.gmail.com, I noticed that with
the new accessor, it will show the actual json field name, for example:
```
evantest=# select (j).b.c from ttt;
c
----
20
(2 rows)
```
"c" is the last segment of the accessor, so the column name shows as "c".
While now "->" and "->" operators will show "?column?" as column names when
accessing Json fields. It had been my concern for many years when I was a
PG user. Now as I started to work on PG itself, I want to change that.
With this PoC patch, it will also use the last segment of an accessor path
as field name:
```
evantest=# select j->'b'->'c' from ttt;
c
----
20
(2 rows)
evantest=# select j#>array['b','c'] from ttt;
c
----
20
(2 rows)
```
But this patch has not handled case of:
```
evantest=# select j#>'{b,c}' from ttt;
?column?
----------
20
(2 rows)
```
Because I don't find an existing function to parse '{b,c}' to an array as
it is the parse phase, array_int() is not usable.
This patch is not ready for review, code is not polished, tests are not
updated. I just want to throw out the idea first to see any interest and
objection.
[1]: /messages/by-id/CAK98qZ1JNNAx4QneJG+eX7iLesOhd6A68FNQVvvHP6Up_THf3A@mail.gmail.com
/messages/by-id/CAK98qZ1JNNAx4QneJG+eX7iLesOhd6A68FNQVvvHP6Up_THf3A@mail.gmail.com
Best regards,
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/