Ticket #12293: django-ignore-mysql-notes.patch
File django-ignore-mysql-notes.patch, 1.9 KB (added by , 15 years ago) |
---|
-
django/db/backends/mysql/base.py
old new 80 80 self.cursor = cursor 81 81 82 82 def execute(self, query, args=None): 83 try: 84 return self.cursor.execute(query, args) 85 except Database.OperationalError, e: 86 # Map some error codes to IntegrityError, since they seem to be 87 # misclassified and Django would prefer the more logical place. 88 if e[0] in self.codes_for_integrityerror: 89 raise Database.IntegrityError(tuple(e)) 90 raise 83 return self._execute_and_catch(self.cursor.execute, query, args) 91 84 92 85 def executemany(self, query, args): 86 return self._execute_and_catch(self.cursor.executemany, query, args) 87 88 def _execute_and_catch(self, execute_func, query, args): 93 89 try: 94 return self.cursor.executemany(query, args)90 return execute_func(query, args) 95 91 except Database.OperationalError, e: 96 92 # Map some error codes to IntegrityError, since they seem to be 97 93 # misclassified and Django would prefer the more logical place. 98 94 if e[0] in self.codes_for_integrityerror: 99 95 raise Database.IntegrityError(tuple(e)) 100 96 raise 97 except Database.Warning, e: 98 try: 99 # Some warnings really are Notes, like with an DROP TABLE IF EXISTS. 100 # We don't want to raise those. 101 warnings = self.cursor.connection.show_warnings() 102 if not (False in [i[0] == 'Note' for i in warnings]): # older python lacks any() 103 return None 104 except AttributeError: # older mysql does not have show_warnings() 105 pass 106 raise 101 107 102 108 def __getattr__(self, attr): 103 109 if attr in self.__dict__: