Code

Ticket #5161: patch_5161.diff

File patch_5161.diff, 1.0 KB (added by durdinator, 7 years ago)
Line 
1Index: django/db/backends/mysql/base.py
2===================================================================
3--- django/db/backends/mysql/base.py    (revision 6206)
4+++ django/db/backends/mysql/base.py    (working copy)
5@@ -24,6 +24,11 @@
6 import types
7 import re
8 
9+# Raise exceptions for database warnings if DEBUG is on
10+if settings.DEBUG:
11+    from warnings import filterwarnings
12+    filterwarnings("error", category=Database.Warning)
13+
14 DatabaseError = Database.DatabaseError
15 IntegrityError = Database.IntegrityError
16 
17@@ -153,7 +158,6 @@
18         return False
19 
20     def _cursor(self, settings):
21-        from warnings import filterwarnings
22         if not self._valid_connection():
23             kwargs = {
24                 'conv': django_conversions,
25@@ -175,8 +179,6 @@
26             kwargs.update(self.options)
27             self.connection = Database.connect(**kwargs)
28         cursor = self.connection.cursor()
29-        if settings.DEBUG:
30-            filterwarnings("error", category=Database.Warning)
31         return cursor
32 
33     def _rollback(self):