Ticket #16811: 16811.patch

File 16811.patch, 1.3 KB (added by Aymeric Augustin, 13 years ago)
  • django/db/__init__.py

    diff -r dd6ad9af49f4 django/db/__init__.py
    a b  
    3939def reset_queries(**kwargs):
    4040    for conn in connections.all():
    4141        conn.queries = []
    42 signals.request_started.connect(reset_queries)
     42if settings.DEBUG:
     43    signals.request_started.connect(reset_queries)
    4344
    4445# Register an event that rolls back the connections
    4546# when a Django request has an exception.
  • django/test/testcases.py

    diff -r dd6ad9af49f4 django/test/testcases.py
    a b  
    220220        self.old_debug_cursor = self.connection.use_debug_cursor
    221221        self.connection.use_debug_cursor = True
    222222        self.starting_queries = len(self.connection.queries)
    223         request_started.disconnect(reset_queries)
     223        if settings.DEBUG:
     224            request_started.disconnect(reset_queries)
    224225        return self
    225226
    226227    def __exit__(self, exc_type, exc_value, traceback):
    227228        self.connection.use_debug_cursor = self.old_debug_cursor
    228         request_started.connect(reset_queries)
     229        if settings.DEBUG:
     230            request_started.connect(reset_queries)
    229231        if exc_type is not None:
    230232            return
    231233
Back to Top