Ticket #126 (closed defect: fixed)
unique_together not working with 3 constraints.
|Reported by:||ashc@…||Owned by:||andrew|
from django.db import models
desc = models.CharField?(max_length=20)
name = models.CharField?(max_length=20)
unique_together = (
('foo', 'bar', 'name',)
10:48 ashc@dev-django:[trunk/gapadventures]> python manage.py migrate southtest zero
Running migrations for southtest:
- Migrating backwards to just after zero. < southtest: 0001_initial
Traceback (most recent call last):
File "/home/ashc/sandbox/project_gotham/trunk/gapadventures/./third_party/south/migration.py", line 246, in run_migrations
File "/home/ashc/sandbox/project_gotham/trunk/gapadventures/southtest/migrations/0001_initial.py", line 52, in backwards
db.delete_unique('southtest_southstuff', ['foo_id', 'bar_id', 'name'])
File "/home/ashc/sandbox/project_gotham/trunk/gapadventures/./third_party/south/db/generic.py", line 328, in delete_unique
raise ValueError?("Cannot find a UNIQUE constraint on table %s, columns %r" % (table_name, columns))
ValueError?: Cannot find a UNIQUE constraint on table southtest_southstuff, columns ['foo_id', 'bar_id', 'name']
! Error found during dry run of migration! Aborting.
I have narrowed it down to _constraints_affecting_columns generator always being empty - though I am not familiar enough with generators.
Also noticed that the SQL in the _constraints_affecting_columns method fails. If you remove the kc.table_schema = 'public' part, the constraints are returned, however that isnt enough to fix the problem.
- Status changed from new to assigned
- Version set to subversion
- Milestone changed from The Future to 0.5
- Status changed from assigned to closed
- Resolution set to fixed