Commits

Anonymous committed f0d9007

Added a test for keep_default not keeping defaults

Comments (0)

Files changed (1)

south/tests/db.py

         db.execute("INSERT INTO test_pki (id, new_pkey, eggs) VALUES (1, 2, 3)")
         db.execute("INSERT INTO test_pki (id, new_pkey, eggs) VALUES (2, 2, 4)")
         db.delete_table("test_pki")
-    
+
     def test_add_columns(self):
         """
         Test adding columns
         db.create_table("test_addc", [
             ('spam', models.BooleanField(default=False)),
             ('eggs', models.IntegerField()),
-        ])
+            ])
         # Add a column
         db.add_column("test_addc", "add1", models.IntegerField(default=3), keep_default=False)
         # Add a FK with keep_default=False (#69)
         db.delete_column("test_addc", "add1")
         db.delete_table("test_addc")
 
+    def test_keep_default_false_does_not_leave_a_default(self):
+        db.create_table("test_keep_default", [
+            ('spam', models.BooleanField(default=False)),
+        ])
+        # Add a column
+        db.add_column("test_keep_default", "test_column_no_default", models.IntegerField(default=3), keep_default=False)
+        # try inserting some data, there should be an error as the non-default column wasn't specified
+        db.execute("INSERT INTO test_keep_default (spam) VALUES (%s)", [False])
+        db.delete_column("test_keep_default", "test_column_no_default")
+        db.delete_table("test_keep_default")
+
     def test_add_nullbool_column(self):
         """
         Test adding NullBoolean columns