Carl Meyer  committed 898fefd

use correct column name when adding fkey in sqlite; fixes #415

  • Participants
  • Parent commits e8c524d
  • Branches default

Comments (0)

Files changed (2)

File south/db/

         # We add columns by remaking the table; even though SQLite supports 
         # adding columns, it doesn't support adding PRIMARY KEY or UNIQUE cols.
         self._remake_table(table_name, added={
-            name: self._column_sql_for_create(table_name, name, field, False),
+            field.column: self._column_sql_for_create(table_name, name, field, False),
     def _remake_table(self, table_name, added={}, renames={}, deleted=[], altered={}):

File south/tests/

         # Add a FK with keep_default=False (#69)
         User = db.mock_model(model_name='User', db_table='auth_user', db_tablespace='', pk_field_name='id', pk_field_type=models.AutoField, pk_field_args=[], pk_field_kwargs={})
         db.add_column("test_addc", "user", models.ForeignKey(User, null=True), keep_default=False)
+        # try selecting from the user_id column to make sure it was actually created
+        db.execute("SELECT user_id FROM test_addc")
         db.delete_column("test_addc", "add1")