json (b) and null fields

Поиск
Список
Период
Сортировка
Искать
От
Andrew Dunstan
Тема
json (b) and null fields
Дата
Msg-id
54257F3C.10303@dunslane.net
Список
Дерево обсуждения
json (b) and null fields Andrew Dunstan <andrew@dunslane.net>
Re: json (b) and null fields Stephen Frost <sfrost@snowman.net>
Re: json (b) and null fields Andrew Dunstan <andrew@dunslane.net>
Re: json (b) and null fields Tom Lane <tgl@sss.pgh.pa.us>
Re: json (b) and null fields Andrew Dunstan <andrew@dunslane.net>
Re: json (b) and null fields Tom Lane <tgl@sss.pgh.pa.us>
Re: json (b) and null fields Andrew Dunstan <andrew@dunslane.net>
Re: json (b) and null fields Robert Haas <robertmhaas@gmail.com>
Re: json (b) and null fields Stephen Frost <sfrost@snowman.net>
Re: json (b) and null fields Merlin Moncure <mmoncure@gmail.com>
Re: json (b) and null fields Stephen Frost <sfrost@snowman.net>
Re: json (b) and null fields Andrew Dunstan <andrew@dunslane.net>
Re: json (b) and null fields Stephen Frost <sfrost@snowman.net>
Re: json (b) and null fields Tom Lane <tgl@sss.pgh.pa.us>
Re: json (b) and null fields "David E. Wheeler" <david@justatheory.com>
Re: json (b) and null fields Pavel Stehule <pavel.stehule@gmail.com>
Re: json (b) and null fields Stephen Frost <sfrost@snowman.net>
Re: json (b) and null fields Andrew Dunstan <andrew@dunslane.net>
Re: json (b) and null fields Pavel Stehule <pavel.stehule@gmail.com>
Re: json (b) and null fields Pavel Stehule <pavel.stehule@gmail.com>
Re: json (b) and null fields Andrew Dunstan <andrew@dunslane.net>
Re: json (b) and null fields Tom Lane <tgl@sss.pgh.pa.us>
Re: json (b) and null fields Andrew Dunstan <andrew@dunslane.net>
Re: json (b) and null fields Tom Lane <tgl@sss.pgh.pa.us>
Re: json (b) and null fields Andrew Dunstan <andrew@dunslane.net>
Re: json (b) and null fields Pavel Stehule <pavel.stehule@gmail.com>
Re: json (b) and null fields Pavel Stehule <pavel.stehule@gmail.com>
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 have nulls ignored,   only the top level will. * it doesn't apply to other json generators, notably json_agg().   That's a very 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
Дата:
От: Robert Haas
Дата:
FAQ