Search Postgresql Archives

Re: string_to_array with empty input

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 31, 2009 at 4:34 PM, Sam Mason <sam@xxxxxxxxxxxxx> wrote:
>
> That's also a disingenuous example; what would you expect back from:
>
>  select count_elements(string_to_array('butter,,milk',','))
>
> I think the semantics you want is what you'd get from:
>
>  array_filter_blanks(string_to_array($1,$2))
>
> where I defined "array_filter_blanks" in my previous post.

I think you're still thinking from a programmers point of view
thinking about string processing.

>From a functional point of view, if I give you a comma separated list
of items which is an empty string and ask you how many items are in it
nobody would normally say there's one empty thing in the list.

Both interpretations are clearly consistent but it depends on whether
you think it's a bunch of text strings concatenated together or if
it's a list of objects.

The example of string_to_array('',',')::int[] is relevant to this
point. The whole "there's one empty element" only makes sense if
you're thinking in terms of string processing. If it's a list of any
other kind of object it probably doesn't make sense; you can't say
there's one empty integer or one empty composite object or one empty
anything else.

-- 
greg

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux