diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-11-10 17:17:08 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2006-11-10 17:17:08 +0000 |
| commit | 527626a19a47f6a477009b9b1109b99ca9b3d77f (patch) | |
| tree | a7e5b2615c7f36129dcb3f512485ff172ccbfff2 /examples | |
| parent | 2466dca12d39643fc8531b7b8807a9850c3a3f9d (diff) | |
| download | sqlalchemy-527626a19a47f6a477009b9b1109b99ca9b3d77f.tar.gz | |
patched **kwargs enhancement for [ticket:361]
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/association/proxied_association.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/examples/association/proxied_association.py b/examples/association/proxied_association.py index 3e80ffa16..e6180ad8a 100644 --- a/examples/association/proxied_association.py +++ b/examples/association/proxied_association.py @@ -35,7 +35,7 @@ metadata.create_all() class Order(object): def __init__(self, customer_name): self.customer_name = customer_name - items = AssociationProxy('itemassociations', 'item', creator=lambda x:OrderItem(x)) + items = AssociationProxy('itemassociations', 'item', creator=lambda x, **kw:OrderItem(x, **kw)) class Item(object): def __init__(self, description, price): @@ -79,6 +79,9 @@ order.itemassociations.append(OrderItem(item('MySQL Crowbar'), 10.99)) order.items.append(item('SA Mug')) order.items.append(item('SA Hat')) +# now append one more item, overriding the price +order.items.append(item('SA T-Shirt'), price=2.99) + session.save(order) session.flush() @@ -97,6 +100,10 @@ print [(item.description, item.price) for item in order.items] result = SelectResults(session.query(Order)).join_to('item').select(and_(items.c.description=='MySQL Crowbar', items.c.price>orderitems.c.price)) print [order.customer_name for order in result] +# print customers who got the special T-shirt discount +result = SelectResults(session.query(Order)).join_to('item').select(and_(items.c.description=='SA T-Shirt', items.c.price>orderitems.c.price)) +print [order.customer_name for order in result] + |
