Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#25393 closed Bug (fixed)

Cannot add TextField with unhashable default with MySQL

Reported by: Ville Skyttä Owned by: nobody
Component: Database layer (models, ORM) Version: dev
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

Adding a TextField that has an unhashable default fails with MySQL, for example with {} as the default:

Traceback (most recent call last):
[...]
  File "[...]/django/db/backends/mysql/schema.py", line 53, in add_field
    if self.skip_default(field) and field.default not in {None, NOT_PROVIDED}:
TypeError: unhashable type: 'dict'

One use case for fields like this is JSONField at https://github.com/bradjasper/django-jsonfield

Change History (14)

comment:2 by Tim Graham, 9 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Markus Holtermann, 9 years ago

Needs documentation: set

comment:4 by Ville Skyttä, 9 years ago

Needs documentation: unset

PR force-updated with commit containing requested docs.

comment:5 by Anton Baklanov, 9 years ago

Patch needs improvement: set

Trivial spelling fix required, see PR.

comment:6 by Ville Skyttä, 9 years ago

Patch needs improvement: unset

PR updated

comment:7 by Anton Baklanov, 9 years ago

Triage Stage: AcceptedReady for checkin

Looks good.

comment:8 by Anton Baklanov, 9 years ago

Triage Stage: Ready for checkinAccepted

comment:9 by Anton Baklanov, 9 years ago

Patch needs improvement: set

comment:10 by Anton Baklanov, 9 years ago

Looks like there is some room for minor test improvement, left two comments on PR.
Thanks.

comment:11 by Ville Skyttä, 9 years ago

Patch needs improvement: unset

PR updated

comment:12 by Anton Baklanov, 9 years ago

Triage Stage: AcceptedReady for checkin

Thanks!

comment:13 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In 4d933ad:

Fixed #25393 -- Fixed MySQL crash when adding text/blob field with unhashable default.

comment:14 by Tim Graham <timograham@…>, 9 years ago

In 69017bad:

[1.8.x] Fixed #25393 -- Fixed MySQL crash when adding text/blob field with unhashable default.

Backport of 4d933ad4181a511f3ced98edba4e17aff054e0e2 from master

Note: See TracTickets for help on using tickets.
Back to Top