dmiller wrote:
> Is there a reason why this doesn't work:
>
> orders = Table('orders', meta,
> Column('id', Integer, Sequence('order_id_seq'), primary_key=True),
> ...
>
> )
> items = Table('items', meta,
> Column('id', Integer, Sequence('item_id_seq'), primary_key=True),
> Column('order_id', Integer, ForeignKey(orders.c.id),
> nullable=False),
> ...
> )
>
> class Order(object): pass
> class Item(object): pass
>
> itemMapper = mapper(Item, items)
> orderMapper = mapper(Order, orders, properties=dict(
> items=relation(itemMapper, backref="order")
> ))
>
> session = create_session()
> order = session.query(Order).get(1) # assume order exists
> itemsNotInOrder = session.query(Item).select(Item.c.order != order) #
> ERROR!
This should work.
itemsNotInOrder = session.query(Item).select(Item.c.order_id != order.id)
>
>
> The Item.c object does not have an 'order' attribute. Is there a
> reason why it can't have one?
I would guess that attributes of Item.c are Column instances, which
order is not. Your approach seems intuitive (I did the same thing
once), but the above example I think is easy enough.
I could be wrong or missing something. Just trying to be helpful.
Randall
>
> ~ Daniel
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---