Modify ↓
Ticket #205 (closed defect: fixed)
add_column fails for unique ForeignKey or OneToOneField
| Reported by: | john.firebaugh@… | Owned by: | andrew |
|---|---|---|---|
| Priority: | major | Milestone: | 0.6 |
| Component: | databaseapi | Version: | 0.6-pre |
| Keywords: | Cc: |
Description
def test_add_unique_fk(self):
"""
Test adding a ForeignKey with unique=True or a OneToOneField
"""
db.create_table("test_add_unique_fk", [
('spam', models.BooleanField(default=False))
])
db.start_transaction()
db.add_column("test_add_unique_fk", "mock1", models.ForeignKey(db.mock_model('Mock', 'mock'), null=True, unique=True))
db.add_column("test_add_unique_fk", "mock2", models.OneToOneField(db.mock_model('Mock', 'mock'), null=True))
db.rollback_transaction()
db.delete_table("test_add_unique_fk")
With a sqlite database, this produces:
OperationalError: table test_add_unique_fk has no column named mock1
when trying to create a unique index on column 'mock1'. It should instead be creating the unique index on column 'mock1_id'.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

Fixed in [da117a13a6cd].