From 37773f34488a5f5d65bf31d5d1b899ea56e6af8a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 22 Jan 2012 17:40:50 -0500 Subject: - adjust the test for [ticket:2377] to be less controversial on problematic backends like Oracle.i - move the check generated in r85017c4310d2 up for both label name/name comparisions, fixes additional mismatches which can occur --- lib/sqlalchemy/engine/base.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 36365e524..db19fe7de 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -2641,22 +2641,25 @@ class ResultMetaData(object): result = map.get(key.lower()) # fallback for targeting a ColumnElement to a textual expression # this is a rare use case which only occurs when matching text() - # constructs to ColumnElements, and after a pickle/unpickle roundtrip + # or colummn('name') constructs to ColumnElements, or after a + # pickle/unpickle roundtrip elif isinstance(key, expression.ColumnElement): if key._label and key._label.lower() in map: result = map[key._label.lower()] elif hasattr(key, 'name') and key.name.lower() in map: - # match is only on name. search - # extra hard to make sure this isn't a column/ - # label name overlap + # match is only on name. result = map[key.name.lower()] - - if result[1] is not None: - for obj in result[1]: - if key._compare_name_for_result(obj): - break - else: - result = None + # search extra hard to make sure this + # isn't a column/label name overlap. + # this check isn't currently available if the row + # was unpickled. + if result is not None and \ + result[1] is not None: + for obj in result[1]: + if key._compare_name_for_result(obj): + break + else: + result = None if result is None: if raiseerr: raise exc.NoSuchColumnError( -- cgit v1.2.1