- changed status to wontfix
NoSuchColumn for column "type"
Issue #2659
resolved
i'm testing an app against tip of rel_0_8 (dd1262e659c62f826bc6806de06610a120bb4c04). It currently runs w/0.7.9. Both are using cx_Oracle 5.1.1. Other tables work, so not sure if this is related to name (type) or not.
#! python
import os, sys
from sqlalchemy import *
from sqlalchemy.orm import *
from sqlalchemy.ext.declarative import declarative_base
if __name__ == '__main__':
engine = create_engine(os.environ['MY_ORACLE_DB']('MY_ORACLE_DB'), echo=True)
Base = declarative_base()
class AccreditingAgency(Base):
__tablename__ = 'WG_REF_ACCREDIT_AGENCY_TYPE'
id = Column('type', Integer, primary_key=True)
name = Column('description', String(100))
def __unicode__(self):
return self.name
Session = sessionmaker(bind=engine)
session = Session()
# works fine
print session.query(AccreditingAgency).count()
# BOOM
# sqlalchemy.exc.NoSuchColumnError: "Could not locate column in row for column 'WG_REF_ACCREDIT_AGENCY_TYPE.type'"
print session.query(AccreditingAgency).all()
# SQL from log is:
# SELECT "WG_REF_ACCREDIT_AGENCY_TYPE".type AS "WG_REF_ACCREDIT_AGENCY_T_1", "WG_REF_ACCREDIT_AGENCY_TYPE".description AS "WG_REF_ACCREDIT_AGENCY_T_2"
# FROM "WG_REF_ACCREDIT_AGENCY_TYPE"
Comments (3)
-
repo owner -
Account Deleted Thanks, that fixed it. I went through change log a couple times, but glossed right over that.
-
repo owner - removed milestone
Removing milestone: 0.8.0final (automated comment)
- Log in to comment
It's very likely you want the
__tablename__
here to be all lower case,"wg_ref_accredit_agency_type"
, else the name will be quoted and sent as UPPERCASE which will then confuse result fetching.The probable cause of the change is due to this: http://docs.sqlalchemy.org/en/rel_0_8/changelog/migration_08.html#case-insensitive-result-row-names-will-be-disabled-in-most-cases
passing
case_sensitive=False
tocreate_engine()
should also resolve this, as this reverts to the 0.7 behavior.I'm pretty sure this is what you're seeing, so it's expected behavior, but if either of these approaches don't fix it, then please reopen - thanks !