#27056: changing dim property for gemotries does not generate correct migration
-------------------------------+----------------------------------------
     Reporter:  billyburly     |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  Uncategorized  |    Version:  1.9
     Severity:  Normal         |   Keywords:  geodjango postgres postgis
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+----------------------------------------
 Changing the dim property for a geometry field does not generate a
 migration that changes the number of dimensions a geometry in the DB has.

 Changing a field in a model from {{{models.LineStringField(null=True)}}}
 to {{{models.LineStringField(null=True, dim=3)}}} creates the following
 migration and sql:

 {{{
 # -*- coding: utf-8 -*-
 # Generated by Django 1.9.8 on 2016-08-12 15:28
 from __future__ import unicode_literals

 import django.contrib.gis.db.models.fields
 from django.db import migrations


 class Migration(migrations.Migration):

     dependencies = [
         ('rivermap', '0026_auto_20160624_1827'),
     ]

     operations = [
         migrations.AlterField(
             model_name='sectionextra',
             name='streamPath',
 field=django.contrib.gis.db.models.fields.LineStringField(dim=3,
 null=True, srid=4326),
         ),
     ]
 }}}
 {{{
 BEGIN;
 --
 -- Alter field streamPath on sectionextra
 --
 ALTER TABLE "rivermap_sectionextra" ALTER COLUMN "streamPath" TYPE
 geometry(LINESTRINGZ,4326) USING "streamPath"::geometry(LINESTRINGZ,4326);

 COMMIT;
 }}}
 This causes an exception during migration because PostGIS returned the
 following error
 {{{
 Column has Z dimension but geometry does not
 }}}

 According to http://gis.stackexchange.com/questions/109410/postgis-column-
 has-z-dimension-but-geometry-does-not the {{{ST_Force3D}}} function needs
 to be used for the USING clause.

--
Ticket URL: <https://code.djangoproject.com/ticket/27056>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.e971bed3d06cc89cc92aa5a03f0199d2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to