Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#22679 closed Bug (fixed)

makemigrations generates invalid code for default_permissions = ()

Reported by: rockallite.wulf@… Owned by: mardini
Component: Migrations Version: dev
Severity: Release blocker Keywords: makemigrations, default_permissions
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This actually happens in Django 1.7b4.

When I define a Model with meta info like this:

class Foo(models.Model):
    # ...
    class Meta:
        default_permissions = ()

The ./manage.py makemigrations command generates a migration file like this:

options={
    # ...
    'default_permissions': (,),
}

...which causes SynaxError on migration.

Change History (4)

comment:1 by mardini, 10 years ago

Has patch: set
Owner: changed from nobody to mardini
Status: newassigned
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug
Version: 1.7-beta-2master

I reproduced. The generated migration had a syntax error.
PR with regression test: https://github.com/django/django/pull/2700

Version 0, edited 10 years ago by mardini (next)

comment:2 by Baptiste Mispelon <bmispelon@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In ad994a3c5b5911a12a5e2f2a8d06c036be1b8ad8:

Fixed #22679 -- Fixed empty tuple serialization in MigrationWriter.

Thanks rockallite.wulf for the report.

comment:3 by Baptiste Mispelon <bmispelon@…>, 10 years ago

In 7d4a51e239bcde34d1614877accb3aa5f5589e0c:

[1.7.x] Fixed #22679 -- Fixed empty tuple serialization in MigrationWriter.

Thanks rockallite.wulf for the report.

Backport of ad994a3c5b5911a12a5e2f2a8d06c036be1b8ad8 from master.

in reply to:  3 comment:4 by Rockallite Wulf <rockallite.wulf@…>, 10 years ago

Replying to Baptiste Mispelon <bmispelon@…>:

In 7d4a51e239bcde34d1614877accb3aa5f5589e0c:

[1.7.x] Fixed #22679 -- Fixed empty tuple serialization in MigrationWriter.

Thanks rockallite.wulf for the report.

Backport of ad994a3c5b5911a12a5e2f2a8d06c036be1b8ad8 from master.

Hi. I found something wrong in that commit:

# From tests/migrations/test_writer.py:134
        one_item_tuple = ('a')

This is wrong. It should be one_item_tuple = ('a',)

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