#23719 closed Bug (fixed)
GIS test failure with MySQL 5.6: BLOB/TEXT column can't have a default value
Reported by: | Tim Graham | Owned by: | Tim Graham |
---|---|---|---|
Component: | GIS | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Possibly it's related to the first "Incompatible change" listed in the MySQL upgrading notes.
django.contrib.gis.tests.gis_migrations.test_operations.OperationTests.test_add_gis_field
:
Traceback (most recent call last): File "/var/lib/jenkins/jobs/django-master/workspace/database/mysql_gis/python/python2.7/django/contrib/gis/tests/gis_migrations/test_operations.py", line 78, in test_add_gis_field operation.database_forwards("gis", editor, project_state, new_state) File "/var/lib/jenkins/jobs/django-master/workspace/database/mysql_gis/python/python2.7/django/db/migrations/operations/fields.py", line 37, in database_forwards field, File "/var/lib/jenkins/jobs/django-master/workspace/database/mysql_gis/python/python2.7/django/contrib/gis/db/backends/mysql/schema.py", line 38, in add_field super(MySQLGISSchemaEditor, self).add_field(model, field) File "/var/lib/jenkins/jobs/django-master/workspace/database/mysql_gis/python/python2.7/django/db/backends/mysql/schema.py", line 45, in add_field super(DatabaseSchemaEditor, self).add_field(model, field) File "/var/lib/jenkins/jobs/django-master/workspace/database/mysql_gis/python/python2.7/django/db/backends/schema.py", line 389, in add_field self.execute(sql) File "/var/lib/jenkins/jobs/django-master/workspace/database/mysql_gis/python/python2.7/django/db/backends/schema.py", line 102, in execute cursor.execute(sql, params) File "/var/lib/jenkins/jobs/django-master/workspace/database/mysql_gis/python/python2.7/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) File "/var/lib/jenkins/jobs/django-master/workspace/database/mysql_gis/python/python2.7/django/db/utils.py", line 95, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/var/lib/jenkins/jobs/django-master/workspace/database/mysql_gis/python/python2.7/django/db/backends/utils.py", line 65, in execute return self.cursor.execute(sql, params) File "/var/lib/jenkins/jobs/django-master/workspace/database/mysql_gis/python/python2.7/django/db/backends/mysql/base.py", line 130, in execute return self.cursor.execute(query, args) File "/var/lib/jenkins/jobs/django-master/workspace/database/mysql_gis/python/python2.7/tests/.env/local/lib/python2.7/site-packages/MySQLdb/cursors.py", line 219, in execute self.errorhandler(self, exc, value) File "/var/lib/jenkins/jobs/django-master/workspace/database/mysql_gis/python/python2.7/tests/.env/local/lib/python2.7/site-packages/MySQLdb/connections.py", line 38, in defaulterrorhandler raise errorvalue OperationalError: (1101, "BLOB/TEXT column 'path' can't have a default value")
Change History (10)
comment:1 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 10 years ago
Yes, that patch works. So unlike CharField/TextField in [1d3d01b4], the default
model field option can't be used with all GeometryFields, correct?
comment:4 by , 10 years ago
I'm not sure to understand your question. However, it seems that MySQL 5.6 is less permissive about DROP
ping default for columns which don't accept defaults. I'm not sure there is a difference between CharField/TextField and GeometryFields. Still, I'd suggest to ask Loic about the best resolution to this issue.
comment:5 by , 10 years ago
You can have something like CharField(default='foo')
since model field defaults aren't applied at the database level. [1d3d01b4] prevents temporarily setting a default on MySQL to prevent the same error as this ticket for Char/TextField.
Is PointField(default=???)
a possibility? If so, it seems your proposal wouldn't solve the issue entirely. We'd need something like my initial proposal (possibly using isinstance(field, GeometryField)
instead). I think your proposal may address #23581 though. I will look at that later today.
comment:6 by , 10 years ago
I've never seen default
values on a geometry column. Even I can't find anything (after a short research) saying that it can never happen, I think it's fine to consider this as unsupported, so your patch goes indeed in the right direction.
comment:8 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Loic gave this a LGTM on IRC.
comment:9 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
As I can see, the problem is not due to the add field instruction, but with the following
ALTER TABLE `gis_neighborhood` ALTER COLUMN `path` DROP DEFAULT'
, while the add field didn't set any default.Applying this might help:
django/db/backends/schema.py
None:#23581 might be related.