Commits

Andrew Godwin committed fda4b44

Fix default datetime test and generic backend

Comments (0)

Files changed (2)

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)

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(
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.