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) return q.select( sajoin ,order_by=asc(sorder) ,limit=800 ) On 1/31/07, Brent Pedersen <[EMAIL PROTECTED]> wrote: > hi, how can put custom sql in a query? specifically in this code? the > problem is with the order_by. i want to pass it some custom sql: > > q = session.query(Student) > sajoin = q.join_to('address') > > return q.select( > sajoin, > order_by="(ABS(address.lat - %s) + ABS(address.lon - %s))" > % (lat,lon) > ,limit=800 > ) > > > > that doesnt work . this does: > order_by=asc((address.c.lat - lat) + (address.c.lon - lon)) > > but it's not quite what i need--the manhattan distance.... > and i'd like the results to be in my mapped objects so > i can still do > student.address.lat, etc. > > i've scoured the docs, but maybe i've missed something. > any pointers? > thanks. > -brent > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---