shaib avatar shaib committed dd7c835

Avoid setting column defaults on alter-column

Comments (0)

Files changed (1)

south/db/generic.py

             sqls.append((self.alter_string_drop_null % params, []))
 
         # Do defaults
-        self._alter_set_defaults(field, name, params, sqls)
+        #self._alter_set_defaults(field, name, params, sqls)
  1. charettes

    This broke two tests on PostgreSQL.

    ======================================================================
    FAIL: test_add_nullbool_column (south.tests.db.TestOperations)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/simon/workspace/south/south/tests/db.py", line 330, in test_add_nullbool_column
        self.assertIsNone(null2, "Null boolean field (added with default) with no value inserted returns non-null")
    AssertionError: Null boolean field (added with default) with no value inserted returns non-null
    
    ======================================================================
    FAIL: test_datetime_default (south.tests.db.TestOperations)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/simon/workspace/south/south/tests/db.py", line 718, in test_datetime_default
        db.execute, statement, [end_of_world, end_of_world]
    AssertionError: IntegrityError not raised
    
    1. shaib author

      I see. The problem this solved was that on SQL Server, the commented-out line caused defaults to be set on alter-column calls. I understand that on PostgreSQL, it is used to remove defaults with an alter-column called from add-column. I'll revert it and fix the SQL Server problem another way.

 
         # Actually change the column (step 1 -- Nullity may need to be fixed)
         if self.allows_combined_alters:
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.