json (b) and null fields

Поиск
Список
Период
Сортировка
От Andrew Dunstan
Тема json (b) and null fields
Дата
Msg-id 54257F3C.10303@dunslane.net
обсуждение исходный текст
Ответы Re: json (b) and null fields  (Stephen Frost <sfrost@snowman.net>)
Список pgsql-hackers
I should have been paying a bit more attention to the recent work on 
adding an ignore_nulls option to row_to_json(). Here are some belated 
thought. I apologize to Pavel and Stephen for not having commented earlier.

I think this is really a bandaid, and it will fail to catch lots of 
cases. Several examples:
 * it doesn't apply recursively, so if the row has a nested composite,   or an array of composites, none of those will
havenulls ignored,   only the top level will. * it doesn't apply to other json generators, notably json_agg().   That's
avery big omission. * it does nothing to allow us to strip nulls from existing json/jsonb   data.
 

I think a much more comprehensive solution would be preferable. What I 
have in mind is something like
    json_strip_null_fields(json) -> json

and a similar function for jsonb.

These would operate recursively. There is a downside, in that they would 
be required to reprocess the json/jsonb. But adding an option like this 
to all the json generator functions would be seriously ugly, especially 
since they are mostly aggregate functions or variadic functions. At 
least in the jsonb case the cost of reprocessing is likely to be fairly low.

cheers

andrew




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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: proposal: rounding up time value less than its unit.
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Replication identifiers, take 3