Ticket #16184: introspection.py.patch

File introspection.py.patch, 1.3 KB (added by radim.blazek@…, 13 years ago)

Patch for multiple 'geometry' types

  • django/contrib/gis/db/backends/postgis/introspection.py

    old new  
    2222        # PostGIS custom data types.
    2323        oid_sql = 'SELECT "oid" FROM "pg_type" WHERE "typname" = %s'
    2424        try:
    25             cursor.execute(oid_sql, ('geometry',))
    26             GEOM_TYPE = cursor.fetchone()[0]
    27             postgis_types = { GEOM_TYPE : 'GeometryField' }
     25            fields = [ ('geometry', 'GeometryField' ) ]
    2826            if self.connection.ops.geography:
    29                 cursor.execute(oid_sql, ('geography',))
    30                 GEOG_TYPE = cursor.fetchone()[0]
    3127                # The value for the geography type is actually a tuple
    3228                # to pass in the `geography=True` keyword to the field
    3329                # definition.
    34                 postgis_types[GEOG_TYPE] = ('GeometryField', {'geography' : True})
     30                fields.append( ( 'geography', ('GeometryField', {'geography' : True})) )
     31
     32            postgis_types = {}
     33            for f in fields:
     34                cursor.execute(oid_sql, (f[0],))
     35                for r in cursor.fetchall():
     36                    postgis_types[r[0]] = f[1]
    3537        finally:
    3638            cursor.close()
    3739
Back to Top