From 9aa8f3039f2216e4fa0e8f89e25c725d77bb48e9 Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Tue, 21 Jul 2009 05:26:26 +0000 Subject: [PATCH] refactor to handle lazy loaded columns raising UnboundExecutionErrors. fixes orm.test_merge test_no_load_with_backrefs on Jython, CPython avoided this due to the luck of dict ordering --- test/orm/_base.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/orm/_base.py b/test/orm/_base.py index 44bfd08a40..f08d253d57 100644 --- a/test/orm/_base.py +++ b/test/orm/_base.py @@ -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)) -- 2.47.3