c result proxy raises NoSuchColumnError for getattr() access, inconsistent with pure python

Issue #2398 resolved
Mike Bayer repo owner created an issue

No description provided.

Comments (4)

  1. Mike Bayer reporter

    patch:

    diff -r 0b97ba8a1410447797c0a1d049b2cfb6cc066ff3 lib/sqlalchemy/cextension/resultproxy.c
    --- a/lib/sqlalchemy/cextension/resultproxy.c   Wed Mar 14 13:10:31 2012 -0700
    +++ b/lib/sqlalchemy/cextension/resultproxy.c   Wed Mar 14 13:47:15 2012 -0700
    @@ -353,7 +353,16 @@
         else
             return tmp;
    
    -    return BaseRowProxy_subscript(self, name);
    +    tmp = BaseRowProxy_subscript(self, name);
    +    if (PyErr_ExceptionMatches(PyExc_KeyError)) {
    +        PyErr_Format(
    +                PyExc_AttributeError, 
    +                "Could not locate column in row for column '%s'",
    +                PyString_AsString(name)
    +            );
    +        return NULL;
    +    }
    +    return tmp;
     }
    
     /***********************
    
  2. Log in to comment