array quotation problem

Поиск
Список
Период
Сортировка
От Sim Zacks
Тема array quotation problem
Дата
Msg-id emt5ei$207f$1@news.hub.org
обсуждение исходный текст
Ответы Re: array quotation problem  (Sim Zacks <sim@compulab.co.il>)
Список pgsql-general
select version();
"PostgreSQL 8.0.1 on i686-pc-linux-gnu, compiled by GCC i686-pc-linux-gnu-gcc (GCC) 3.3.5  (Gentoo
Linux 3.3.5-r1, ssp-3.3.2-3, pie-8.7.7.1)"

In short:
Does anyone have any idea of how to put non escaped quotes into a text array element in the same way
that the system puts non escaped quotes around the text of an element that has whitespace within?

Details:
I am using a text array and when there are spaces in the text, the parser automatically puts double
quotes around the element and when there are no special characters it doesn't, as is written in the
documentation.

I would like to put double quotes around all the elements, even the ones without special characters
and I can't figure out how. The double quotes that the system automatically puts in are not escaped
with a \, but when I add quotes they are escaped (again as written in the documentation). If have
tried using chr(32) and quote_ident() and they work the same way.

My specific problem is that I am passing the array into a python function and converting it to a
python list type. The array gets passed in as a comma delimited string. If the values are already
quoted (without escapes) then it can be converted automatically. Otherwise I have to write a parsing
routine to check which of the elements have quotes (the ones that had a space) and which don't and
then to put in the quotes manually before I can convert it to a list type.

According to the documentation:
> The array output routine will put double quotes around element values if they are empty strings,
> contain curly braces, delimiter characters, double quotes, backslashes, or white space, or
 > match the word NULL. Double quotes and backslashes embedded in element values will be
backslash-escaped.
> For numeric data types it is safe to assume that double quotes will never appear, but for textual
> data types one should be prepared to cope with either presence or absence of quotes.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: ORDER BY col is NULL in UNION causes error?
Следующее
От: "Albe Laurenz"
Дата:
Сообщение: Re: DB problem