Re: string_to_array with an empty input string

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: string_to_array with an empty input string
Дата
Msg-id AANLkTimLmEc46Hi0Jt-0-VphnsePbkwzq3mKiNYddwg4@mail.gmail.com
обсуждение исходный текст
Ответ на Re: string_to_array with an empty input string  (Peter Geoghegan <peter.geoghegan86@gmail.com>)
Ответы Re: string_to_array with an empty input string  (Greg Stark <gsstark@mit.edu>)
Re: string_to_array with an empty input string  (Pavel Stehule <pavel.stehule@gmail.com>)
Re: string_to_array with an empty input string  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Wed, Aug 11, 2010 at 12:37 AM, Peter Geoghegan
<peter.geoghegan86@gmail.com> wrote:
> On 10 August 2010 19:48, David E. Wheeler <david@kineticode.com> wrote:
>> On Aug 10, 2010, at 11:46 AM, Thom Brown wrote:
>>
>>> I, personally, would expect an empty array output given an empty
>>> input, and a null output for a null input.
>>
>> +1
>
> Agreed. After all, the result isn't indeterminate - it's an empty
> array. Some people might think that it's useful for the result to be
> NULL, but they'd probably also think that it's useful for an empty
> string to be NULL.
>

For what it's worth there are two reasonable return values for
string_to_array(''). It could be [] or it could be ['']. There are
applications where the former makes the most sense and there are
applications where the latter makes the most sense.

Ideally you really want string_to_array(array_to_string(x, ':'),':')
to return x. There's no safe return value to pick for the cases where
x=[''] and x=[] that will make this work.

-- 
greg


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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: assertions and constraint triggers
Следующее
От: Greg Stark
Дата:
Сообщение: Re: string_to_array with an empty input string