Ticket #205 (closed defect: fixed)

Opened 6 years ago

Last modified 4 years ago

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:


    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.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))

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'.

Change History

comment:1 Changed 6 years ago by andrew

  • Status changed from new to closed
  • Resolution set to fixed
  • Version set to Mercurial tip
  • Component changed from commands to databaseapi
  • Milestone set to 0.6

Fixed in [da117a13a6cd].

Note: See TracTickets for help on using tickets.