summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-09-14 22:05:58 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-09-14 22:05:58 +0000
commitdfdbf9ec1e50ac0416297503b05322cdd2f5234a (patch)
treebe896279900831aff432dd2a4d7c52243a1f527e
parent59964c2c3fba3a59d43e7514e1478cca46852595 (diff)
Fixed #5161 -- Changed MySQL backend only to report warning once. Thanks, durdinator
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6229 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/backends/mysql/base.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index f913b88709..92eac6ea3e 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -24,6 +24,11 @@ from MySQLdb.constants import FIELD_TYPE
import types
import re
+# Raise exceptions for database warnings if DEBUG is on
+if settings.DEBUG:
+ from warnings import filterwarnings
+ filterwarnings("error", category=Database.Warning)
+
DatabaseError = Database.DatabaseError
IntegrityError = Database.IntegrityError
@@ -153,7 +158,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
return False
def _cursor(self, settings):
- from warnings import filterwarnings
if not self._valid_connection():
kwargs = {
'conv': django_conversions,
@@ -175,8 +179,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
kwargs.update(self.options)
self.connection = Database.connect(**kwargs)
cursor = self.connection.cursor()
- if settings.DEBUG:
- filterwarnings("error", category=Database.Warning)
return cursor
def _rollback(self):