Ticket #16184: introspection.py.patch
File introspection.py.patch, 1.3 KB (added by , 13 years ago) |
---|
-
django/contrib/gis/db/backends/postgis/introspection.py
old new 22 22 # PostGIS custom data types. 23 23 oid_sql = 'SELECT "oid" FROM "pg_type" WHERE "typname" = %s' 24 24 try: 25 cursor.execute(oid_sql, ('geometry',)) 26 GEOM_TYPE = cursor.fetchone()[0] 27 postgis_types = { GEOM_TYPE : 'GeometryField' } 25 fields = [ ('geometry', 'GeometryField' ) ] 28 26 if self.connection.ops.geography: 29 cursor.execute(oid_sql, ('geography',))30 GEOG_TYPE = cursor.fetchone()[0]31 27 # The value for the geography type is actually a tuple 32 28 # to pass in the `geography=True` keyword to the field 33 29 # 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] 35 37 finally: 36 38 cursor.close() 37 39