Ticket #3615: set-foreign-key-checks-on-managed-trans.diff

File set-foreign-key-checks-on-managed-trans.diff, 5.3 KB (added by Andrew Sutherland <andrew@…>, 17 years ago)

ugly implementation of workaround proposed in ticket description

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

     
    8484        if self.connection is not None:
    8585            return self.connection.rollback()
    8686
     87    def _disable_broken_foreign_key_checks(self):
     88        pass
     89   
     90    def _enable_broken_foreign_key_checks(self):
     91        pass
     92
    8793    def close(self):
    8894        if self.connection is not None:
    8995            self.connection.close()
  • django/db/backends/mysql_old/base.py

     
    120120            except Database.NotSupportedError:
    121121                pass
    122122
     123    def _disable_broken_foreign_key_checks(self):
     124        pass
     125   
     126    def _enable_broken_foreign_key_checks(self):
     127        pass
     128
    123129    def close(self):
    124130        if self.connection is not None:
    125131            self.connection.close()
  • django/db/backends/postgresql/base.py

     
    100100        if self.connection is not None:
    101101            return self.connection.rollback()
    102102
     103    def _disable_broken_foreign_key_checks(self):
     104        pass
     105   
     106    def _enable_broken_foreign_key_checks(self):
     107        pass
     108
    103109    def close(self):
    104110        if self.connection is not None:
    105111            self.connection.close()
  • django/db/backends/sqlite3/base.py

     
    8282        if self.connection is not None:
    8383            self.connection.rollback()
    8484
     85    def _disable_broken_foreign_key_checks(self):
     86        pass
     87   
     88    def _enable_broken_foreign_key_checks(self):
     89        pass
     90
    8591    def close(self):
    8692        from django.conf import settings
    8793        # If database is in memory, closing the connection destroys the database.
  • django/db/backends/mysql/base.py

     
    118118                self.connection.rollback()
    119119            except Database.NotSupportedError:
    120120                pass
     121   
     122    def _disable_broken_foreign_key_checks(self):
     123        if self.connection is not None:
     124            self.connection.cursor().execute('SET FOREIGN_KEY_CHECKS = 0;')
     125   
     126    def _enable_broken_foreign_key_checks(self):
     127        if self.connection is not None:
     128            self.connection.cursor().execute('SET FOREIGN_KEY_CHECKS = 1;')
    121129
    122130    def close(self):
    123131        if self.connection is not None:
  • django/db/backends/oracle/base.py

     
    5454            except Database.NotSupportedError:
    5555                pass
    5656
     57    def _disable_broken_foreign_key_checks(self):
     58        pass
     59   
     60    def _enable_broken_foreign_key_checks(self):
     61        pass
     62
    5763    def close(self):
    5864        if self.connection is not None:
    5965            self.connection.close()
  • django/db/backends/postgresql_psycopg2/base.py

     
    6868        if self.connection is not None:
    6969            return self.connection.rollback()
    7070
     71    def _disable_broken_foreign_key_checks(self):
     72        pass
     73   
     74    def _enable_broken_foreign_key_checks(self):
     75        pass
     76
    7177    def close(self):
    7278        if self.connection is not None:
    7379            self.connection.close()
  • django/db/backends/dummy/base.py

     
    2525    cursor = complain
    2626    _commit = complain
    2727    _rollback = ignore
     28    _disable_broken_foreign_key_checks = ignore
     29    _enable_broken_foreign_key_checks = ignore
    2830
    2931    def __init__(self, **kwargs):
    3032        pass
  • django/db/transaction.py

     
    5353        state[thread_ident].append(settings.TRANSACTIONS_MANAGED)
    5454    if thread_ident not in dirty:
    5555        dirty[thread_ident] = False
     56    connection._disable_broken_foreign_key_checks()
    5657
    5758def leave_transaction_management():
    5859    """
     
    6869    if dirty.get(thread_ident, False):
    6970        rollback()
    7071        raise TransactionManagementError("Transaction managed block ended with pending COMMIT/ROLLBACK")
     72    connection._enable_broken_foreign_key_checks()
    7173    dirty[thread_ident] = False
    7274
    7375def is_dirty():
Back to Top