Support needed for user-defined types

Bug #412000 reported by Dan Halbert
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pg8000
Fix Committed
Undecided
Mariano Reingart

Bug Description

User-defined types (e.g. ENUM) are not supported. They generate errors like "type oid 16785 not mapped to py type".

Perhaps they could be supported as strings; psycopg2 does this. psycopg2 also also a type-extension mechanism for fancier type conversions.

Revision history for this message
Mike Bayer (zzzeek) wrote :

Test case:

from pg8000 import dbapi

connection = dbapi.connect(user='scott', password='tiger', host='localhost', database='test')

cursor = connection.cursor()

cursor.execute("CREATE TYPE mytype AS ENUM ('one', 'two', 'three')")
cursor.execute("CREATE TABLE mytable (somedata mytype)")
cursor.execute("INSERT INTO mytable (somedata) VALUES (%s)", ["two"])

produces:

pg8000.errors.ProgrammingError: ('ERROR', '42804', 'column "somedata" is of type mytype but expression is of type text')

Revision history for this message
Mariano Reingart (reingart) wrote :

I've made a maintenance fork:

http://code.google.com/p/pg8000/

With the test case I've added two patches, one for new_type and register_type (in a similar fashion like psycopg2) and register_default for unknown types

You can see the fix at:

http://code.google.com/p/pg8000/source/detail?r=b7c16fbc8494d473df5bf23d2ff2bf089aeed151

http://code.google.com/p/pg8000/source/detail?r=bdd4c5f6a5b351316f556627f58b18fe26fcbcac

If you have new issues, if you can please report it in the googlecode project issues

Changed in pg8000:
assignee: nobody → Mariano Reingart (reingart)
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.