INET type and arrays: too much casting?

Stephane Bortzmeyer <[email protected]>
Newsgroups gmane.comp.python.db.psycopg.devel
Organization NIC France
Message-ID <[email protected]>
If I create a table:

CREATE TABLE Foobar (addr INET);

psycopg2 can write data just fine:

>>> cursor.execute("""INSERT INTO Foobar VALUES (%s)""", ["2001::1"])
>>> 

But if the column has an array type:

CREATE TABLE Foobar (addr INET[]);

psycopg2 can no longer insert data:

>>> cursor.execute("""INSERT INTO Foobar VALUES (%s)""", [["2001::1", "2001:db8::dead:babe"]])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
psycopg2.ProgrammingError: column "addr" is of type inet[] but expression is of type text[]
HINT:  You will need to rewrite or cast the expression.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.