Ticket #678 (assigned enhancement)

Opened 5 years ago

Last modified 5 years ago

If a field's default is set to an Enum, the resulting migration has a syntax error

Reported by: virtue@… Owned by: andrew
Priority: minor Milestone: 1.0
Component: migrations Version: unknown
Keywords: Cc:


I had code like this:

ENUM1 = Enum(...)
field1 = models.CharField?(max_length=100, default=ENUM1.SOME_VALUE)

The resulting migration had a typo, since it put the repr() of the value into the migration file:

default=EnumValue?(<enum.Enum object at 0x018C9F70>, 0, 'SOME_VALUE')

It's probably a bad idea to add an object as the default - this should probably have a str(ENUM1.SOME_VALUE) instead.

But the point of this ticket is better error reporting. It'd be nice if south would show an error when *creating* a migration. Right now it only shows a syntax error when running the migration.

Change History

comment:1 Changed 5 years ago by andrew

  • Status changed from new to assigned
  • Milestone set to 1.0

Good point, more robust errors before you run things would be nice.

Note: See TracTickets for help on using tickets.