1. Andrew Godwin
  2. south

Commits

Andrew Godwin  committed 018d493

Oh look, MySQL doesn't do defaults properly. HOW SURPRISING.

  • Participants
  • Parent commits 4402a8e
  • Branches default

Comments (0)

Files changed (3)

File south/db/generic.py

View file
  • Ignore whitespace
     supports_foreign_keys = True
     has_check_constraints = True
     has_booleans = True
+    raises_default_errors = True
 
     @cached_property
     def has_ddl_transactions(self):

File south/db/mysql.py

View file
  • Ignore whitespace
 
     allows_combined_alters = False
     has_check_constraints = False
+    raises_default_errors = False
 
     geom_types = ['geometry', 'point', 'linestring', 'polygon']
     text_types = ['text', 'blob']

File south/tests/db.py

View file
  • Ignore whitespace
 import datetime
+from warnings import filterwarnings
 
 from south.db import db, generic
 from django.db import connection, models, IntegrityError as DjangoIntegrityError
 
     def setUp(self):
         db.debug = False
+        try:
+            import MySQLdb
+        except ImportError:
+            pass
+        else:
+            filterwarnings('ignore', category=MySQLdb.Warning)
         db.clear_deferred_sql()
         db.start_transaction()
     
         else:
             self.fail("Non-existent table could be selected!")
     
+    @skipUnless(db.raises_default_errors, 'This database does not raise errors on missing defaults.')
     def test_create_default(self):
         """
         Test creation of tables, make sure defaults are not left in the database
         after = text_type(after) # Oracle text fields return a sort of lazy string -- force evaluation
         self.assertEqual(value, after, "Change from char to text altered value [ %r != %r ]" % (value, after))
 
+    @skipUnless(db.raises_default_errors, 'This database does not raise errors on missing defaults.')
     def test_datetime_default(self):
         """
         Test that defaults are correctly not created for datetime columns