Commits

Anonymous committed 95662fd

Minor efficiency

Comments (0)

Files changed (1)

         """
         monkey patches django.db.models.sql.compiler.SQL*Compiler series
         """
+        if self._patched: return
         from django.db.models.sql import compiler
 
         self._read_compilers = (
             compiler.SQLDeleteCompiler,
             compiler.SQLUpdateCompiler,
         )
-        if not self._patched:
-            self._original = {}
-            for reader in self._read_compilers:
-                self._original[reader] = reader.execute_sql
-                reader.execute_sql = self._monkey_select(reader.execute_sql)
-            for updater in self._write_compilers:
-                self._original[updater] = updater.execute_sql
-                updater.execute_sql = self._monkey_write(updater.execute_sql)
-            self._patched = True
-            self.cache_backend.patch()
-            self._handle_signals()
+
+        self._original = {}
+        for reader in self._read_compilers:
+            self._original[reader] = reader.execute_sql
+            reader.execute_sql = self._monkey_select(reader.execute_sql)
+        for updater in self._write_compilers:
+            self._original[updater] = updater.execute_sql
+            updater.execute_sql = self._monkey_write(updater.execute_sql)
+        self._patched = True
+        self.cache_backend.patch()
+        self._handle_signals()
 
     def unpatch(self):
         """un-applies this patch."""