Hi all,

I've got a function that makes the following query:

results = session.query(Order) \
     .filter_by(reference=reference) \
     .order_by(asc(Order.order_id)) \
     .options(eagerload("item"), \
                 eagerload("state_ref"), \
                 eagerload("item.book_ref"), \
                 eagerload("item.cover_type_ref"), \
                 eagerload("item.cover_material_ref"), \
                 eagerload("item.cover_color_ref"), \
                 eagerload("item.book_ref.product_ref")) \
      .add_column((Order.item.gross *
Order.item.qty).label("total"))
      .all()

where item and state_ref are FK references in Order and book_ref,
cover_type_ref, cover_material_ref and cover_color_ref are FK
reference in Item and product_ref is a FK refeference in Book.

I want to add a new column to create a "total" for each row returned
from Order, but I'm getting the following exception when the

.add_column((Order.item.gross * Order.item.qty).label("total"))

is executed:

AttributeError: Neither 'InstrumentedAttribute' object nor
'Comparator' object has an attribute 'gross'

How can I make add_column() aware of the to gross and qty I want to
multiple together?

Thanks in advance for your help!
Doug

-- 
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