initcap() whitespace bug

Started by Darrell Walisserover 21 years ago3 messagesbugs
Jump to latest
#1Darrell Walisser
dwalisser@mediak.com

It appears that "'" is being considered as a whitespace (and perhaps other
punctuation, haven't checked myself):

initcap(text) " Convert first letter of each word (whitespace-separated) to
upper case "

Sample SQL: select initcap('grahm''s little angel');

Incorrect Result (Note capital S): 'Grahm'S Little Angel'

Postgresql Version: 7.4.5

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Darrell Walisser (#1)
Re: initcap() whitespace bug

"Darrell Walisser" <dwalisser@mediak.com> writes:

It appears that "'" is being considered as a whitespace (and perhaps other
punctuation, haven't checked myself):

Hmm. The documentation is at variance with the code, which clearly says

* Returns string, with first letter of each word in uppercase, all
* other letters in lowercase. A word is defined as a sequence of
* alphanumeric characters, delimited by non-alphanumeric
* characters.

and indeed implements it that way.

It looks like we changed the code to match what Oracle does on
7/27/2003, but forgot to fix the documentation. Will fix, thanks
for the report.

regards, tom lane

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tom Lane (#2)
Re: initcap() whitespace bug

I wrote:

It looks like we changed the code to match what Oracle does on
7/27/2003, but forgot to fix the documentation. Will fix, thanks
for the report.

Actually, someone already fixed the documentation in CVS tip: see
http://developer.postgresql.org/docs/postgres/functions-string.html

regards, tom lane