It is not a bug (as I define it). SImply you are not allowed in the
DAL to alias the table that is not joined. The reason you are not
allowed to do it is that it it not necessary. You also another
problem, your main filter (t1.id==123) involves the joined table. That
is not no allowed in SQL. This would work fine and my guess it is what
you want.

print db(table2.id==123).select(t1.id,table2.name,
left=t1.on(t1.key==table2.key))

Anyway, the purpose of aliasing is when a joining a table with itself
or joining the same table multiple times. In all the other cases it is
useless so web2py does not allow it.

On Mar 12, 2:32 am, Alexey Nezhdanov <[email protected]> wrote:
> Hello. Here is everything that is needed to reproduce the bug. All code is
> in models/db.py.
> web2py is the latest released version (1.76.5)
>
>
>
> /home/snake/python/web2py/1.76.5/web2py/applications/ttt/models/db.py(77)<module>()->None
> -> import pdb;pdb.set_trace()
> (Pdb) l 70
>  65     db.define_table('mytable1',
>  66         Field('key','string')
>  67     )
>  68
>  69     db.define_table('mytable2',
>  70         Field('key','string'),
>  71         Field('name','string')
>  72     )
>  73
>  74     t1=db.mytable1.with_alias('t1')
>  75     t2=db.mytable2.with_alias('t2')
> (Pdb)
>  76
>  77  -> import pdb;pdb.set_trace()
> [EOF]
> (Pdb) print db(t1.id==123)._select(t1.id,t2.name,
> left=t1.on(t1.key==t2.key))
> SELECT t1.id, t2.name FROM t2 LEFT JOIN mytable1 AS t1 ON t1.key=t2.key
> WHERE t1.id=123;
> (Pdb) print db(t1.id==123).select(t1.id,t2.name, left=t1.on(t1.key==t2.key))
> *** OperationalError: no such table: t2
> (Pdb)
>
> -- Regards
> Alexey Nezhdanov

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" 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/web2py?hl=en.

Reply via email to