logging needs to be updated for non-booleanable? tables

Issue #1620 resolved
Former user created an issue

This code breaks when DEBUG logging is turned all the way on because it can't get the boolean value of a Table. Should it really check for 'is not None'?

Index: orm/mapper.py
===================================================================
--- orm/mapper.py       (revision 6510)
+++ orm/mapper.py       (working copy)
@@ -735,8 +735,8 @@
             self.logger.info(
                 "(" + self.class_.__name__ + 
                 "|" + 
-                (self.local_table and self.local_table.description or str(self.local_table)) +
-                (self.non_primary and "|non-primary" or "") + ") " + 
+                (self.local_table is not None and self.local_table.description or str(self.local_table)) +
+                (self.non_primary is not None and "|non-primary" or "") + ") " + 
                 msg)

     def _log_debug(self, msg):
@@ -744,8 +744,8 @@
             self.logger.debug(
                 "(" + self.class_.__name__ + 
                 "|" + 
-                (self.local_table and self.local_table.description or str(self.local_table)) + 
-                (self.non_primary and "|non-primary" or "") + ") " + 
+                (self.local_table is not None and self.local_table.description or str(self.local_table)) + 
+                (self.non_primary is not None and "|non-primary" or "") + ") " + 
                 msg)

     def __repr__(self):

Comments (4)

  1. Former user Account Deleted

    I think that patch is wrong because everything shows up with |non-primary. Still, it is preferable to having the application crash just because logging is turned on.

  2. Mike Bayer repo owner
    • changed component to orm
    • changed milestone to 0.6.0

    non_primary is in fact a boolean so that should be left as it was before. the local_table is not None part is correct.

  3. Log in to comment