In web2py you can alias tables but not fields just because that is all you
need to resolve ambigious joins. The aliasing of fields is not necessary
functionally. You want:
star = db.person.with_alias('star')
dir = db.person.with_alias('dir')
db(db.movie.title == 'Citizen Kane').select(db.movie.title, star*.name <as
star**>*, dir*.name,*
left = [db.actor.on(db.movie.id == db.actor.movie_id),
star.on(db.actor.person_id == star.id),
db.director.on(db.movie.id == db.director.movie_id),
dir.on(db.director.person_id == dir.id)]
On Wednesday, 29 August 2012 17:10:46 UTC-5, Mike Girard wrote:
>
> Hello,
>
> Could someone tell me how I should modify the following to alias the
> results for actor and director? Both actors and directors consist of a
> movie_id and a person_id, linking them up respectively to a person.id and
> a movie.id.
>
> db(db.movie.title == 'Citizen Kane').select(db.movie.title, *db**.person.name
> <as star**>*, *db**.person.name <as director**>*,
> left = [db.actor.on(db.movie.id == db.actor.movie_id),
> db.person.on(db.actor.person_id == db.person.id),
> db.director.on(db.movie.id == db.director.movie_id),
> db.person.on(db.director.person_id == db.person.id)]
> )
>
>
>
> Not crufting this up with my model since I think this is a syntax issue.
> My model is very standard many-to-many.
>
>
>
>
>
--