Commits

shaib committed 11b3b13

Remove redundant "FATAL ERROR" messages on Oracle
For this, let caller of db.execute() control error printing

  • Participants
  • Parent commits 463114d

Comments (0)

Files changed (2)

south/db/generic.py

         """
         return self._get_connection().ops.quote_name(name)
 
-    def execute(self, sql, params=[]):
+    def _print_sql_error(self, e, sql, params=[]):
+        print('FATAL ERROR - The following SQL query failed: %s' % sql, file=sys.stderr)
+        print('The error was: %s' % e, file=sys.stderr)
+        
+    def execute(self, sql, params=[], print_all_errors=True):
         """
         Executes the given SQL statement, with optional parameters.
         If the instance's debug attribute is True, prints out what it executes.
         try:
             cursor.execute(sql, params)
         except DatabaseError as e:
-            print('FATAL ERROR - The following SQL query failed: %s' % sql, file=sys.stderr)
-            print('The error was: %s' % e, file=sys.stderr)
+            if print_all_errors:
+                self._print_sql_error(e, sql, params)
             raise
 
         try:

south/db/oracle.py

 
         for sql_template, params in sql_templates:
             try:
-                self.execute(sql_template % params)
+                self.execute(sql_template % params, print_all_errors=False)
             except DatabaseError as exc:
                 description = str(exc)
                 # Oracle complains if a column is already NULL/NOT NULL
                 elif 'ORA-22858' in description or 'ORA-22859' in description:
                     self._alter_column_lob_workaround(table_name, name, field)
                 else:
+                    self._print_sql_error(exc, sql_template % params)
                     raise
 
     def _alter_column_lob_workaround(self, table_name, name, field):