Opened 8 years ago

Closed 8 years ago

Last modified 8 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 Changed 8 years ago by mardini

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

I could reproduce the bug. The generated migration had a syntax error.
PR with regression test: https://github.com/django/django/pull/2700
Thanks.

Last edited 8 years ago by mardini (previous) (diff)

comment:2 Changed 8 years ago by Baptiste Mispelon <bmispelon@…>

Resolution: fixed
Status: assignedclosed

In ad994a3c5b5911a12a5e2f2a8d06c036be1b8ad8:

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

Thanks rockallite.wulf for the report.

comment:3 Changed 8 years ago by 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.

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

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