- changed status to resolved
- changed component to orm
- marked as major
- changed milestone to 0.8.xx
- marked as bug
Misleading error message
Issue #2888
resolved
Consider the following tables:
class Unit(Base):
__tablename__ = 'unit'
id = Column(Integer, primary_key=True)
name = Column(String(20))
def __repr__(self):
return "<%s:%s:%s>" % (self.__class__.__name__,self.id,self.name)
class HourData(Base):
__tablename__ = 'hourdata'
id = Column(Integer, primary_key=True)
datum = Column(Date, nullable=False)
hour = Column(Integer, nullable=False)
unit_id = Column(Integer, ForeignKey('unit.id', name="fk_hd_unit", use_alter=True), nullable=False)
unit = relationship("unit", backref='hours')
Executing this statement
session.query(Unit)
Then results in this error message:
sqlalchemy.exc.ArgumentError: Class object expected, got 'Table('unit', MetaData(bind=None), Column('id', Integer(), table=<unit>, primary_key=True, nullable=False), Column('name', String(length=20), table=<unit>), Column('mieter_id', Integer(), ForeignKey('mieter.id'), table=<unit>, nullable=False), schema=None)'.
This is totally misleading, because the actual error is in table HourData – whose relationship statement is supposed to refer to "Unit" instead of "unit". An error like this is impossible to figure out unless you happen to find the explanation in stackoverflow.
Thus, please fix this error message. It should at least tell me which relationship statement in which table is actually broken.
Comments (2)
-
repo owner -
repo owner - removed milestone
Removing milestone: 0.8.xx (automated comment)
- Log in to comment
I'm very sorry you had a problem! I hope the solution here works for you.
69154698d20d1c15cee83990ec719d1deaf193ae 0.8
ace7bdbc78571619cb103d57a188fbe6aa92b627 0.9