On Jul 4, 2011, at 2:29 AM, Michael Tils wrote:

> 
> rating = aliased(BuildingRating)
> care_level = aliased(BuildingCareLevel)
> 
> to make later:
> 
> .....query(Building).filter( or_( rating.value.like("%good"),
> care_level.value.like("well_groomed") ) )
> 
> But I couldn't work out how to explicit name the aliased classes or
> get the aliased name. If I could do something like:
> 
> rating = aliased(BuildingRating)
> care_level = aliased(BuildingCareLevel)
> 
> query = session.query(Building).join('condition',
> rating).join('condition', care_level)
> query = query.filter( or_( care_level.value.like('well-groomed'),
> rating.value.like('%good') )  )

this is nearly a valid query.   join is called as in join(rating, 
Building.condition), join(care_level, Building.condition).   Assuming 
BuildingRating and BuildingCareLevel are both single table off of whatever 
Building.condition is it should be straightforward.


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