Re: Using JSONB with nested key-value structures, andskipping/wildcarding the key

Поиск
Список
Период
Сортировка
От Alban Hertroys
Тема Re: Using JSONB with nested key-value structures, andskipping/wildcarding the key
Дата
Msg-id FB580CA8-7660-4579-9165-9AEDACA12957@gmail.com
обсуждение исходный текст
Ответ на Re: Using JSONB with nested key-value structures, andskipping/wildcarding the key  (Shaheed Haque <shaheedhaque@gmail.com>)
Список pgsql-general
> On 2 Jun 2020, at 9:30, Shaheed Haque <shaheedhaque@gmail.com> wrote:
>
>
>> I do something like this to get a set of sub-paths in a JSONB field (no idea how to write that in Django):
>>
>> select snapshot->’pay_definition’->k.value->’name’
>>   from MyModel
>>   join lateral jsonb_object_keys(snapshot->’pay_definition’) k(value) on true
>>
> I was unaware of the LATERAL keyword, so thanks. After a bit of Googling however, it seems that it is
tricky/impossibleto use from the ORM (barring a full scale escape to a "raw" query). One question: as a novice here, I
thinkI understand the right hand side of your JOIN "... k(value)" is shorthand for: 
>
> ... AS table_name(column_name)
>
> except that I don't see any clues in the docs that jsonb_object_keys() is a "table function". Can you kindly clarify?

Correct. Thomas already explained the return type, but the plural form of the function name is also an indication that
itreturns multiple results. 

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.




В списке pgsql-general по дате отправления:

Предыдущее
От: Paul Förster
Дата:
Сообщение: Re: Patroni
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Fine grained permissions on User Mapping