[Sqlrelay-discussion] getColumnType returns 'UNKNOWN' for PostgreSQL ARRAY column type.
Brought to you by:
mused
|
From: Alfred J F. <alf...@gm...> - 2007-09-05 20:29:55
|
Hi everyone,
I am using SQLRelay 0.38 via Python (2.4.4) to connect to a PostgreSQL (
8.1.9) database. I have noticed that if I create a table with an ARRAY
column, that Sqlrelay returns the column type as UNKNOWN. E.g., if I issue
the following SQL:
CREATE TABLE test (arr TEXT[][]);
And fill it will some test data:
INSERT INTO test (arr) VALUES (ARRAY[['fname', 'alfred'], ['lname',
'fazio'], ['age', '24'], ['employer', 'smoothstone']]);
I will get an UNKNOWN value when calling getColumnType on the arr column
above:
>>> c.sendQuery("SELECT arr FROM test")
>>> c.getField(0, 0)
'{{fname,alfred},{lname,fazio},{age,24},{employer,smoothstone}}'
>>> c.getColumnType(0)
'UNKNOWN'
It would be very convenient if I could test whether the column I am fetching
is an ARRAY. If so, I can automatically parse the result of the query into
a native Python list. I briefly peeked in the source code and saw that
there has been a datatype declared for arrays for PostgreSQL in the
src/common/datatypes.h file (called 'ANYARRAY'). However, I didn't look
around for long to see where I might implement the code needed to detect the
column type. Could somebody please point me to the right direction within
the source code where I can perhaps add a clause for this situation? I will
then be happy to submit a patch to the list.
Thanks for your time!
--
Alfred J Fazio,
alf...@gm...
|