Hi there,

I use the earthdistance and cube modules for PostgreSQL (http://
www.postgresql.org/docs/8.4/interactive/earthdistance.html). These
define some custom types and functions for doing great circle
calculations. I ran into a problem with table introspection in
PGDialect.get_columns().

The columns and domains fetched look like this (note that the 'earth'
type defined by the earthdistance module has the base type of 'cube'
from the cube module):

rows = [
 (u'id', u'integer', u"nextval('mytable_id_seq'::regclass)", True, 1,
161772),
 (u'created_at', u'timestamp without time zone', None, True, 2,
161772),
 (u'name', u'character varying(255)', None, True, 3, 161772),
 (u'lat', u'numeric(10,7)', None, False, 4, 161772),
 (u'lng', u'numeric(10,7)', None, False, 5, 161772),
 (u'earth', u'earth', None, False, 6, 161772)
]

domains = {
 u'earth': {'attype': u'cube', 'default': None, 'nullable': True},
 u'information_schema.cardinal_number': {'attype': u'integer',
                                         'default': None,
                                         'nullable': True},
 u'information_schema.character_data': {'attype': u'character
varying',
                                        'default': None,
                                        'nullable': True},
 u'information_schema.sql_identifier': {'attype': u'character
varying',
                                        'default': None,
                                        'nullable': True},
 u'information_schema.time_stamp': {'attype': u'timestamp',
                                    'default':
u"('now'::text)::timestamp(2) with time zone",
                                    'nullable': True}
}

The problem is that in the loop through the rows in
PGDialect.get_columns(), the 'earth' column's attype is in the
dictionary of domains, but the domain attype (cube) is not in
self.ischema_names. So coltype is never initialized, and it ends up
having the value of the previous for loop iteration, causing it to
fail with "TypeError: 'NUMERIC' object is not callable" (because the
previous iteration ran coltype = coltype(...)).

The expected behaviour is obviously for `coltype` to become
sqltypes.NULLTYPE. It can be solved by initializing coltype = None
inside the for loop.

Thanks,

N

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to