Ticket #16455: django-trunk-postgis2-version1.0.patch
File django-trunk-postgis2-version1.0.patch, 2.5 KB (added by , 13 years ago) |
---|
-
django/contrib/gis/db/backends/postgis/creation.py
### Eclipse Workspace Patch 1.0 #P django-trunk
10 10 from django.contrib.gis.db.models.fields import GeometryField 11 11 12 12 output = super(PostGISCreation, self).sql_indexes_for_field(model, f, style) 13 13 14 postgis_version = self.connection.introspection.get_postgis_version() 15 14 16 if isinstance(f, GeometryField): 15 17 gqn = self.connection.ops.geo_quote_name 16 18 qn = self.connection.ops.quote_name … … 45 47 if f.geography: 46 48 index_opts = '' 47 49 else: 48 index_opts = ' ' + style.SQL_KEYWORD(self.geom_index_opts) 50 # Check for PostGIS Version 51 # PostGIS 2.0 does not support GIST_GEOMETRY_OPS 52 if postgis_version >= (2, 0): 53 index_opts = '' 54 else: 55 index_opts = ' ' + style.SQL_KEYWORD(self.geom_index_opts) 49 56 output.append(style.SQL_KEYWORD('CREATE INDEX ') + 50 57 style.SQL_TABLE(qn('%s_%s_id' % (db_table, f.column))) + 51 58 style.SQL_KEYWORD(' ON ') + -
django/contrib/gis/db/backends/postgis/introspection.py
93 93 cursor.close() 94 94 95 95 return field_type, field_params 96 97 def get_postgis_version(self): 98 """ 99 Returns the current postgis version as a tuple 100 """ 101 cursor = self.connection.cursor() 102 # an alternate would be "postgis_full_version" 103 v_sql = 'SELECT postgis_version()' 104 postgis_version = (1,5) 105 try: 106 cursor.execute(v_sql) 107 VERSION = cursor.fetchone()[0] 108 # Converts the string 109 # "2.0 USE_GEOS=1 USE_PROJ=1 USE_STATS=1" 110 # to a tuple (2, 0) 111 postgis_version = tuple([int(s) for s in VERSION[0:4].split('.')]) 112 113 finally: 114 cursor.close() 115 116 return postgis_version 117