Skip to content

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

Closed
@sqlalchemy-bot

Description

@sqlalchemy-bot
Collaborator

Migrated issue, originally created by Michael Bayer (@zzzeek)


Attachments: 2398.patch

Activity

sqlalchemy-bot

sqlalchemy-bot commented on Mar 14, 2012

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

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;
 }
 
 /***********************
sqlalchemy-bot

sqlalchemy-bot commented on Mar 14, 2012

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

full patch w changelog

sqlalchemy-bot

sqlalchemy-bot commented on Mar 14, 2012

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • attached file 2398.patch
sqlalchemy-bot

sqlalchemy-bot commented on Mar 14, 2012

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

7ad0c8c

sqlalchemy-bot

sqlalchemy-bot commented on Mar 14, 2012

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
added this to the 0.7.6 milestone on Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingsql

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sqlalchemy-bot

        Issue actions

          c result proxy raises NoSuchColumnError for getattr() access, inconsistent with pure python · Issue #2398 · sqlalchemy/sqlalchemy