Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #17513 -- Prevented the MySQL backend from leaking MySQLdb-spec…

…ific exceptions. Thanks Claude Paroz.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17352 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ca187fea88b626508e125e0843c991fe63f8ed95 1 parent f460035
Aymeric Augustin authored January 07, 2012
2  django/db/backends/mysql/base.py
@@ -119,7 +119,7 @@ def executemany(self, query, args):
119 119
             # misclassified and Django would prefer the more logical place.
120 120
             if e[0] in self.codes_for_integrityerror:
121 121
                 raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2]
122  
-            raise
  122
+            raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2]
123 123
         except Database.DatabaseError, e:
124 124
             raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2]
125 125
 
6  tests/regressiontests/backends/tests.py
@@ -351,6 +351,12 @@ def test_database_operations_helper_class(self):
351 351
         self.assertTrue(hasattr(connection.ops, 'connection'))
352 352
         self.assertEqual(connection, connection.ops.connection)
353 353
 
  354
+    def test_duplicate_table_error(self):
  355
+        """ Test that creating an existing table returns a DatabaseError """
  356
+        cursor = connection.cursor()
  357
+        query = 'CREATE TABLE %s (id INTEGER);' % models.Article._meta.db_table
  358
+        with self.assertRaises(DatabaseError):
  359
+            cursor.execute(query)
354 360
 
355 361
 # We don't make these tests conditional because that means we would need to
356 362
 # check and differentiate between:

0 notes on commit ca187fe

Please sign in to comment.
Something went wrong with that request. Please try again.