Commits

Andrew Godwin  committed fda4b44

Fix default datetime test and generic backend

  • Participants
  • Parent commits 9722bbb

Comments (0)

Files changed (2)

File south/db/generic.py

         else:
             sqls.append((self.alter_string_drop_null % params, []))
 
+        # Do defaults
+        self._alter_set_defaults(field, name, params, sqls)
+
         # Actually change the column (step 1 -- Nullity may need to be fixed)
         if self.allows_combined_alters:
             sqls, values = zip(*sqls)

File south/tests/db.py

         # insert a row
         db.execute("INSERT INTO test_datetime_def (col0, col1, col2) values (null,%s,null)", [end_of_world])
         db.alter_column("test_datetime_def", "col2", models.DateTimeField(default=end_of_world))
-        db.add_column("test_datetime_def", "col3", models.DateTimeField(default=end_of_world))
+        db.add_column("test_datetime_def", "col3", models.DateTimeField(default=end_of_world), keep_default=False)
  1. shaib

    I thought the there was a decision to stop leaving defaults in the database; marking keep_default=False in this test (and the nullbool test) runs counter to this decision.

    The proper way to fix these tests is to make the MySql and Postgres backends not leave defaults, like the other three backends already do.

    1. Andrew Godwin author

      I agree, but I needed to get a release out and couldn't have a failing test in there. I'll see if I can get the other backends fixed up for 0.8.1, which is inevitably soon as there's a breaking bug with Django 1.4 and below.

         db.execute_deferred_sql()
         db.commit_transaction()
         # In the single existing row, we now expect col1=col2=col3=end_of_world...
         for e in ends:
             self.failUnlessEqual(e, end_of_world)
         db.commit_transaction()
-        # ...but there should not be a default in the database for any column (other than the 'null' for col0)
-        for cols in ["col1,col2", "col1,col3","col2,col3"]:
+        # ...but there should not be a default in the database for col1 or col3
+        for cols in ["col1,col2", "col2,col3"]:
             db.start_transaction()
             statement = "insert into test_datetime_def (col0,%s) values (null,%%s,%%s)" % cols
             self.assertRaises(