On Jul 18, 2008, at 10:07 AM, Vladimir Iliev wrote:

>
> hi,
>
> i have a method that returns list of (material, thickness) groups  
> which
> looks like:
>
>         C = [order_element_items.c.material_uuid,
>              materials.c.name,
>              order_element_items.c.thickness]
>         S = select(
>             C, order_element_items.c.material_uuid==materials.c.uuid,
>             from_obj=[order_element_items, materials],
>             order_by=[materials.c.name,  
> order_element_items.c.thickness],
>             group_by=C,
>         )
>         res = [(session.query(Material).filter_by(uuid=a).one(), c)  
> for
> a,b,c in session.bind.execute(S)]
>
>
> but it does too many selects and i wonder is it possible somehow to
> achieve the same result with one select?
> \

something along the lines of (using 0.5):

session.query(Material, S.c.thickness).select_from(materials.join(S,  
materials.c.uuid==S.c.material_uuid)).all()

0.4 would be along the lines of  
sess 
.query 
(Material).add_column(OrderElementItem.thickness).select_from(....)

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