Commits

Olemis Lang  committed 81400a4

BH Multiproduct #355 : Logging SQL queries at testing time

  • Participants
  • Parent commits 1847185
  • Branches t355_trac_test_suite

Comments (0)

Files changed (2)

 #t288/t288_r1438538_sql_translate_global_env.diff
 t288/t288_r1438538_sql_translate_global_env_pending.diff
+t288/t288_r1440987_dbcursor_debug_sql.diff
 #t115/t115_r1437383_inherit_product_config.diff
 #t333/t333_r1427886_schema_autoinc.diff
 #t333/t333_r1427886_mp_gen_schema.diff

File t288/t288_r1440987_dbcursor_debug_sql.diff

+# HG changeset patch
+# Parent 504ca48f1d77fc904f93d70c60f28440fa7f73e7
+BH Multiproduct #288 : Log translated SQL queries by default at testing time
+
+diff -r 504ca48f1d77 bloodhound_multiproduct/multiproduct/dbcursor.py
+--- a/bloodhound_multiproduct/multiproduct/dbcursor.py	Fri Feb 01 00:02:30 2013 -0500
++++ b/bloodhound_multiproduct/multiproduct/dbcursor.py	Fri Feb 01 00:54:21 2013 -0500
+@@ -16,6 +16,7 @@
+ #  specific language governing permissions and limitations
+ #  under the License.
+ 
++from trac.db.api import DatabaseManager
+ import trac.db.util
+ from trac.util import concurrency
+ 
+@@ -55,7 +56,9 @@
+     def _translate_sql(self, sql):
+         if self._translator is translator_not_set:
+             self._translator = None
+-            if not self.env is None:
++            if self.env is not None:
++                if DatabaseManager(self.env).debug_sql:
++                    self.log = self.env.log
+                 product_prefix = self.env.product.prefix if self.env.product else GLOBAL_PRODUCT
+                 self._translator = BloodhoundProductSQLTranslate(SKIP_TABLES,
+                                                                  TRANSLATE_TABLES,
+diff -r 504ca48f1d77 bloodhound_multiproduct/tests/env.py
+--- a/bloodhound_multiproduct/tests/env.py	Fri Feb 01 00:02:30 2013 -0500
++++ b/bloodhound_multiproduct/tests/env.py	Fri Feb 01 00:54:21 2013 -0500
+@@ -138,6 +138,10 @@
+         config.set('logging', 'log_file', logpath)
+         config.set('logging', 'log_type', 'file')
+         config.set('logging', 'log_level', 'DEBUG')
++
++        # Log SQL queries
++        config.set('trac', 'debug_sql', True)
++
+         config.save()
+         env.setup_log()
+         env.log.info('%s test case: %s %s',