[Django] #27056: changing dim property for gemotries does not generate correct migration

47 views
Skip to first unread message

Django

unread,
Aug 12, 2016, 11:46:12 AM8/12/16
to django-...@googlegroups.com
#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.

Django

unread,
Aug 12, 2016, 11:55:53 AM8/12/16
to django-...@googlegroups.com
#27056: changing dim property for gemotries does not generate correct migration
-------------------------------------+-------------------------------------

Reporter: billyburly | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: geodjango postgres | Triage Stage: Accepted
postgis |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by charettes):

* needs_better_patch: => 0
* component: Uncategorized => Migrations
* needs_tests: => 0
* version: 1.9 => master
* needs_docs: => 0
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/27056#comment:1>

Django

unread,
Sep 18, 2016, 3:53:21 PM9/18/16
to django-...@googlegroups.com
#27056: changing dim property for gemotries does not generate correct migration
-------------------------------------+-------------------------------------

Reporter: billyburly | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: geodjango postgres | Triage Stage: Accepted
postgis |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* has_patch: 0 => 1


Comment:

I added a pull request to fix this on PostGIS:
[https://github.com/django/django/pull/7264 PR].

On Spatialite, things are currently a bit messy, for several different
reasons. It's currently not possible to alter geometry fields on
Spatialite. I would suggest to commit the PostGIS changes and to open
another ticket specific to Spatialite (which might take longer to solve).

--
Ticket URL: <https://code.djangoproject.com/ticket/27056#comment:2>

Django

unread,
Sep 21, 2016, 7:22:51 PM9/21/16
to django-...@googlegroups.com
#27056: changing dim property for geometries does not generate correct migration on
PostgreSQL
-------------------------------------+-------------------------------------
Reporter: Bill Durr | Owner: nobody
Type: Bug | Status: new

Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: geodjango postgres | Triage Stage: Ready for
postgis | checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Ready for checkin


Comment:

Looks good, pending a few cosmetic issues.

--
Ticket URL: <https://code.djangoproject.com/ticket/27056#comment:3>

Django

unread,
Sep 22, 2016, 11:39:55 AM9/22/16
to django-...@googlegroups.com
#27056: changing dim property for geometries does not generate correct migration on
PostgreSQL
-------------------------------------+-------------------------------------
Reporter: Bill Durr | Owner: nobody
Type: Bug | Status: new

Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: geodjango postgres | Triage Stage: Ready for
postgis | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Claude Paroz <claude@…>):

In [changeset:"8e2ac3bcafb34e4f10be20f24e37319522459095" 8e2ac3b]:
{{{
#!CommitTicketReference repository=""
revision="8e2ac3bcafb34e4f10be20f24e37319522459095"
Refs #27056 -- Rearranged gis_migrations test case classes
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27056#comment:4>

Django

unread,
Sep 22, 2016, 11:39:55 AM9/22/16
to django-...@googlegroups.com
#27056: changing dim property for geometries does not generate correct migration on
PostgreSQL
-------------------------------------+-------------------------------------
Reporter: Bill Durr | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: fixed

Keywords: geodjango postgres | Triage Stage: Ready for
postgis | checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz <claude@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"92323d54fd6df077dc523c423c7bb2dd8dbde621" 92323d54]:
{{{
#!CommitTicketReference repository=""
revision="92323d54fd6df077dc523c423c7bb2dd8dbde621"
Fixed #27056 -- Allowed migrating geometry field dimension on PostGIS

Thanks Tim Graham for the review.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27056#comment:5>

Reply all
Reply to author
Forward
0 new messages