ah. that makes sense.
here's my working query. returns results in order of distance to a
point (lat,lon):
q = session.query(Student)
j = q.join_to('address')
return q.select(
j,order_by=asc(func.abs(address.c.lat -lat) +
func.abs(address.c.lon-lon))
use func.abs(q.address.lat) for the ABS function.
On Jan 31, 2007, at 4:24 PM, Brent Pedersen wrote:
>
> hi, i've got it this far now. but it doesnt like the q.address.lat/lon
> since it makes an alias in the join. how to i get at that alias?
>
>
> sajoin = q.join_to('address')
>
hi, i've got it this far now. but it doesnt like the q.address.lat/lon
since it makes an alias in the join. how to i get at that alias?
sajoin = q.join_to('address')
sorder = "ABS(" + str(q.address.lat) +" - %f) + ABS(" +
str(q.address.lon) +" - %f)"
sorder %= (lat,lon)