summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/db/backends/mysql/base.py2
-rw-r--r--tests/regressiontests/backends/tests.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 8ce2c11344..02bdda199b 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -119,7 +119,7 @@ class CursorWrapper(object):
# misclassified and Django would prefer the more logical place.
if e[0] in self.codes_for_integrityerror:
raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2]
- raise
+ raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2]
except Database.DatabaseError, e:
raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2]
diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py
index b561b4eb2d..436da8c2d0 100644
--- a/tests/regressiontests/backends/tests.py
+++ b/tests/regressiontests/backends/tests.py
@@ -351,6 +351,12 @@ class BackendTestCase(TestCase):
self.assertTrue(hasattr(connection.ops, 'connection'))
self.assertEqual(connection, connection.ops.connection)
+ def test_duplicate_table_error(self):
+ """ Test that creating an existing table returns a DatabaseError """
+ cursor = connection.cursor()
+ query = 'CREATE TABLE %s (id INTEGER);' % models.Article._meta.db_table
+ with self.assertRaises(DatabaseError):
+ cursor.execute(query)
# We don't make these tests conditional because that means we would need to
# check and differentiate between: