Ticket #16455: 16455-v5.diff

File 16455-v5.diff, 1.3 KB (added by Flavio Curella, 12 years ago)
  • django/contrib/gis/db/backends/postgis/creation.py

    diff --git a/django/contrib/gis/db/backends/postgis/creation.py b/django/contrib/gis/db/backends/postgis/creation.py
    index bad22be..1eac429 100644
    a b class PostGISCreation(DatabaseCreation):  
    1010        from django.contrib.gis.db.models.fields import GeometryField
    1111
    1212        output = super(PostGISCreation, self).sql_indexes_for_field(model, f, style)
     13        postgis_version = self.connection.ops.spatial_version
    1314
    1415        if isinstance(f, GeometryField):
    1516            gqn = self.connection.ops.geo_quote_name
    class PostGISCreation(DatabaseCreation):  
    3839                                  style.SQL_FIELD(qn(f.column)) +
    3940                                  style.SQL_KEYWORD(' SET NOT NULL') + ';')
    4041
    41 
    4242            if f.spatial_index:
    4343                # Spatial indexes created the same way for both Geometry and
    4444                # Geography columns
    45                 if f.geography:
     45                # PostGIS 2.0 does not support GIST_GEOMETRY_OPS
     46                if postgis_version >= (2, 0) or f.geography:
    4647                    index_opts = ''
    4748                else:
    4849                    index_opts = ' ' + style.SQL_KEYWORD(self.geom_index_opts)
Back to Top