Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Arrays of INET type not properly parsed into a list

#181

An array of INET is returned as an unparsed string while and array of TEXT is parsed correctly and returned as a list of strings.
I tested on 2.5.1 and 2.4.6 and got the same result.

import psycopg2 conn = psycopg2.connect(host='test', database='schema_test_3') cur = conn.cursor() cur.execute("SELECT ips from hardware LIMIT 20;") cur.next()

('{127.0.0.1,10.10.1.16}',)

cur.execute("SELECT roles from hardware LIMIT 20;") cur.next()

(['ALLHOSTS', 'DEBIANHOSTS'],)

Reported by Dave Rawks · September 26th, 2013 @ 10:06 PM

State: invalid
Milestone: none
Assigned to: nobody

Activity

  1. Daniele Varrazzo
    Daniele Varrazzo
    • State changed from new to invalid

    Please follow the new_array_type example to see how to create a generic array type caster.

    >>> cur.execute("select '{127.0.0.1,10.10.1.16}'::inet[]")
    >>> print cur.fetchone()
    ('{127.0.0.1,10.10.1.16}',)
    
    >>> cur.execute("select typarray from pg_type where typname = 'inet'")
    >>> print cur.fetchone()
    (1041,)
    
    >>> psycopg2.extensions.register_type(
    ...     psycopg2.extensions.new_array_type(
    ...         (1041,), 'INET[]', psycopg2.STRING))
    
    >>> cur.execute("select '{127.0.0.1,10.10.1.16}'::inet[]")
    >>> print cur.fetchone()
    (['127.0.0.1', '10.10.1.16'],)
    

    October 21st, 2013 @ 02:13 PM