Is it possible to group or order by a field in a many to one related table?

> class Rental(Base):
>     __tablename__ = 'rental'
> 
>     rental_id = Column(Integer, autoincrement=True, primary_key=True)
>     inventory_id = Column(Integer, ForeignKey(Inventory.inventory_id), 
> nullable=False)
>     
>     inventory = relation(Inventory,
>         uselist=False,
>         backref='rentals',
>     )

> class Inventory(Base):
>     __tablename__ = 'inventory'
> 
>     inventory_id = Column(Integer, autoincrement=True, primary_key=True)
>     film_id = Column(Integer, ForeignKey(Film.film_id), nullable=False)
>     
>     film = relation(Film,
>         uselist=False,
>         backref='inventory',
>     )



session.query(Rental).order_by(Rental.inventory.film_id)  generates the error:

Neither 'InstrumentedAttribute' object nor 'Comparator' object has an attribute 
'film_id'

Thanks,
Mark

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to