]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
refactor to handle lazy loaded columns raising UnboundExecutionErrors. fixes
authorPhilip Jenvey <pjenvey@underboss.org>
Tue, 21 Jul 2009 05:26:26 +0000 (05:26 +0000)
committerPhilip Jenvey <pjenvey@underboss.org>
Tue, 21 Jul 2009 05:26:26 +0000 (05:26 +0000)
orm.test_merge test_no_load_with_backrefs on Jython, CPython avoided this due
to the luck of dict ordering

test/orm/_base.py

index 44bfd08a4007669a4b2388eb854f742bd1bfbc53..f08d253d57666adceeaadc52e14d01dd3fd85237 100644 (file)
@@ -2,6 +2,7 @@ import inspect
 import sys
 import types
 import sqlalchemy as sa
+import sqlalchemy.exceptions as sa_exc
 from sqlalchemy.test import config, testing
 from sqlalchemy.test.testing import resolve_artifact_names, adict
 from sqlalchemy.test.engines import drop_all_tables
@@ -74,20 +75,19 @@ class ComparableEntity(BasicEntity):
                 if attr.startswith('_'):
                     continue
                 value = getattr(a, attr)
-                if (hasattr(value, '__iter__') and
-                    not isinstance(value, basestring)):
-                    try:
-                        # catch AttributeError so that lazy loaders trigger
-                        battr = getattr(b, attr)
-                    except AttributeError:
-                        return False
 
+                try:
+                    # handle lazy loader errors
+                    battr = getattr(b, attr)
+                except (AttributeError, sa_exc.UnboundExecutionError):
+                    return False
+
+                if hasattr(value, '__iter__'):
                     if list(value) != list(battr):
                         return False
                 else:
-                    if value is not None:
-                        if value != getattr(b, attr, None):
-                            return False
+                    if value is not None and value != battr:
+                        return False
             return True
         finally:
             _recursion_stack.remove(id(self))