Here's a rudimentary test which has "Client_ID" and "client_id" at the same time in the query. It renders as:
SELECT a.client_id AS "Client_ID", a.id AS a_id, a.client_id AS a_client_id FROM a the SQL being generated on your end is key here. from sqlalchemy import * from sqlalchemy.orm import * from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) client_id = Column(Integer) e = create_engine("postgresql://scott:tiger@localhost/test", echo=True) c = e.connect() tr = c.begin() Base.metadata.create_all(c) sess = Session(c) sess.add(A(client_id=5)) sess.commit() print(sess.query(A.client_id.label("Client_ID"), A).all()) On Oct 10, 2013, at 12:59 PM, Michael Bayer <mike...@zzzcomputing.com> wrote: > > On Oct 10, 2013, at 8:34 AM, Ryan Kelly <rpkell...@gmail.com> wrote: > >> Hi: >> >> One of our applications is generating the following error: >> >> NoSuchColumnError: "Could not locate column in row for column >> 'client.claims.client_id'" >> >> Which is rather strange, because that column is aliased with .label() to >> "AS Client_ID", so of course that row cannot be located. > > when the SQL is actually rendered, is the "Client_ID" name rendered with > quotes? it should be, as that is a case-sensitive name. > > 0.8 made a change regarding upper/lower case names which is that we no longer > call lower() on identifier names when producing lookup dictionaries for > result rows - see > http://docs.sqlalchemy.org/en/rel_0_8/changelog/migration_08.html#case-insensitive-result-row-names-will-be-disabled-in-most-cases > > > or the failure here might have something to do with a conflicting "client_id" > name elsewhere in the query. > > you might want to see is sending "case_sensitive=False" to create_engine() > restores the working behavior you saw in 0.7. > > it does sound like something originating within your query and how SQLAlchemy > handles it, psycopg2 is unlikely to be playing a role here. > >
signature.asc
Description: Message signed with OpenPGP using GPGMail