Ticket #288 (closed defect: fixed)
altering a column in sqlite fails when Meta.unique_together is defined
|Reported by:||legutierr@…||Owned by:||andrew|
|Keywords:||sqlite3.OperationalError: Cannot add a NOT NULL column with default value NULL||Cc:|
There is a problem when altering a column in sqlite.
I debugged the problem by stepping through the code into the south.db.sqlite3.DatabaseOperations object. An exception is thrown at line 96.
The failure takes place because the object thinks for some reason that the Meta.unique_together items are fields to be included in the field list of the SQL create statement. Of course, the items in the Meta.unique_together list are the names of actual listed fields so SQLite raises an exception.
This is what I saw stepping through the code, thrown by cursor.execute(sql) at line 96:
OperationalError: 'duplicate column name: name'
This is what I saw when running the program outside of pdb:
sqlite3.OperationalError: Cannot add a NOT NULL column with default value NULL
I cannot find the origin of the problem or a fix, but it is relevant that self._fields["<table_name>"] is an incorrect list (i.e. it lists the Meta.unique_together items as fields, which list is then used to construct the sql), so the problem may be in the constructor.
I don't have time to learn the system enough to create a patch, but this may be enough of a start to fix the problem.
- Status changed from new to assigned
- Milestone changed from 0.6.3 to 0.7