[Django] #29058: Adding 'null=True' to a PointField doesn't create working migration

17 views
Skip to first unread message

Django

unread,
Jan 25, 2018, 6:29:11 AM1/25/18
to django-...@googlegroups.com
#29058: Adding 'null=True' to a PointField doesn't create working migration
-------------------------------------+-------------------------------------
Reporter: Yaman | Owner: nobody
Ozakin |
Type: Bug | Status: new
Component: | Version: 1.11
Migrations | Keywords: geodjango,
Severity: Normal | pointfield
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
before:

{{{
class House(models.Model):
point = models.PointField()
}}}

after:

{{{
class House(models.Model):
point = models.PointField(null=True)
}}}

migration:
{{{
class Migration(migrations.Migration):

dependencies = [
('myapp', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='house',
name='point',
field=django.contrib.gis.db.models.fields.PointField(null=True,
srid=4326),
),
]
}}}

Traceback:

{{{
python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, myapp, sessions
Running migrations:
Applying myapp.0002_auto_20180125_1119...Traceback (most recent call
last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/Basia/yamyam/research/django/myenv/lib/python3.6/site-
packages/django/core/management/__init__.py", line 364, in
execute_from_command_line
utility.execute()
File "/Users/Basia/yamyam/research/django/myenv/lib/python3.6/site-
packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/Basia/yamyam/research/django/myenv/lib/python3.6/site-
packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/Basia/yamyam/research/django/myenv/lib/python3.6/site-
packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/Users/Basia/yamyam/research/django/myenv/lib/python3.6/site-
packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/Users/Basia/yamyam/research/django/myenv/lib/python3.6/site-
packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake,
fake_initial=fake_initial)
File "/Users/Basia/yamyam/research/django/myenv/lib/python3.6/site-
packages/django/db/migrations/executor.py", line 145, in
_migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake,
fake_initial=fake_initial)
File "/Users/Basia/yamyam/research/django/myenv/lib/python3.6/site-
packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/Users/Basia/yamyam/research/django/myenv/lib/python3.6/site-
packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state,
project_state)
File "/Users/Basia/yamyam/research/django/myenv/lib/python3.6/site-
packages/django/db/migrations/operations/fields.py", line 216, in
database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "/Users/Basia/yamyam/research/django/myenv/lib/python3.6/site-
packages/django/db/backends/base/schema.py", line 494, in alter_field
(old_field, new_field),
ValueError: Cannot alter field myapp.House.point into myapp.House.point -
they do not properly define db_type (are you using a badly-written custom
field?)
}}}

Using Spatialite as backend engine.

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

Django

unread,
Jan 25, 2018, 11:56:29 AM1/25/18
to django-...@googlegroups.com
#29058: Adding 'null=True' to a PointField doesn't create working migration
-------------------------------------+-------------------------------------
Reporter: Yaman Ozakin | Owner: nobody
Type: Bug | Status: new
Component: GIS | Version: 1.11
Severity: Normal | Resolution:
Keywords: geodjango, | Triage Stage: Accepted
pointfield |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* component: Migrations => GIS
* stage: Unreviewed => Accepted


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

Django

unread,
Apr 11, 2018, 8:04:14 AM4/11/18
to django-...@googlegroups.com
#29058: Adding 'null=True' to a PointField doesn't create working migration
-------------------------------------+-------------------------------------
Reporter: Yaman Ozakin | Owner: nobody
Type: Bug | Status: new

Component: GIS | Version: 1.11
Severity: Normal | Resolution:
Keywords: geodjango, | Triage Stage: Accepted
pointfield |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Jani Tiainen):

This is actually more widespread problem with spatialite backend.

DB geometry field in spatialite backend is defined as None which causes
any kind of migration, even just adding verbose name which doesn't change
field type nor anything database related to cause error message.

All other spatial backends seem to return at least some kind of a db field
type.

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

Django

unread,
Nov 17, 2019, 9:17:47 PM11/17/19
to django-...@googlegroups.com
#29058: Adding 'null=True' to a PointField doesn't create working migration
-------------------------------------+-------------------------------------
Reporter: Yaman Ozakin | Owner: Victor
| Munene
Type: Bug | Status: assigned

Component: GIS | Version: 1.11
Severity: Normal | Resolution:
Keywords: geodjango, | Triage Stage: Accepted
pointfield |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Victor Munene):

* owner: nobody => Victor Munene
* status: new => assigned


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

Django

unread,
Nov 17, 2019, 10:05:32 PM11/17/19
to django-...@googlegroups.com
#29058: Adding 'null=True' to a PointField doesn't create working migration
-------------------------------------+-------------------------------------
Reporter: Yaman Ozakin | Owner: Victor
| Munene
Type: Bug | Status: assigned
Component: GIS | Version: 1.11
Severity: Normal | Resolution:
Keywords: geodjango, | Triage Stage: Accepted
pointfield |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Victor Munene):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/12090 PR]

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

Django

unread,
Nov 21, 2019, 4:56:50 AM11/21/19
to django-...@googlegroups.com
#29058: Adding 'null=True' to a PointField doesn't create working migration
-------------------------------------+-------------------------------------
Reporter: Yaman Ozakin | Owner: Victor
| Munene
Type: Bug | Status: assigned
Component: GIS | Version: master

Severity: Normal | Resolution:
Keywords: geodjango, | Triage Stage: Accepted
pointfield |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1
* version: 1.11 => master


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

Reply all
Reply to author
Forward
0 new messages