Ticket #17513: 17513-1.diff

File 17513-1.diff, 1.5 KB (added by Claude Paroz, 13 years ago)

Fix error raised and test

  • django/db/backends/mysql/base.py

    diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
    index 8ce2c11..02bdda1 100644
    a b class CursorWrapper(object):  
    119119            # misclassified and Django would prefer the more logical place.
    120120            if e[0] in self.codes_for_integrityerror:
    121121                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]
    123123        except Database.DatabaseError, e:
    124124            raise utils.DatabaseError, utils.DatabaseError(*tuple(e)), sys.exc_info()[2]
    125125
  • tests/regressiontests/backends/tests.py

    diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py
    index b561b4e..436da8c 100644
    a b class BackendTestCase(TestCase):  
    351351        self.assertTrue(hasattr(connection.ops, 'connection'))
    352352        self.assertEqual(connection, connection.ops.connection)
    353353
     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)
    354360
    355361# We don't make these tests conditional because that means we would need to
    356362# check and differentiate between:
Back to Top