I'ts working, but it's results a WHERE JOIN and takes much more time than JOIN sintax :(
2013/10/29 Massimo Di Pierro <massimo.dipie...@gmail.com> > Try this: > > rows = db(db.groups.id == db.lab.group_id)(db.lab.id == > db.researcher_lab_permission.l**ab_id)(db.researcher.id == > db.researcher_lab_permission.r**esearcher_id)(db.researcher.us**er_id == > db.auth_user.id).select(db.**groups.name <http://db.groups.name/>, > db.city.name,db.**auth_user.ALL) > > > On Monday, 28 October 2013 21:46:28 UTC-5, Diogo Munaro wrote: > >> Here is the sql generated: >> >> SELECT groups.name, city.name, auth_user.email, name1.id, >> name1.is_active, name1.created_on, name1.created_by, name1.modified_on, >> name1.modified_by, name1.user_id, name1.image, name1.image_file, >> name1.lattes, name2.id, name2.is_active, name2.created_on, >> name2.created_by, name2.modified_on, name2.modified_by, name2.site, >> name2.url, name2.cnpj, name2.type_id, name2.group_id, name2.privacity FROM >> researcher_lab_permission, researcher, lab JOIN groups ON ((groups.id = >> lab.group_id) AND (groups.is_active = 'T')) JOIN city ON (city.id = >> groups.city_id) JOIN auth_user ON ((researcher.user_id = auth_user.id) >> AND (auth_user.is_active = 'T')) JOIN `researcher` AS name1 ON ( >> researcher.id = researcher_lab_permission.**researcher_id) JOIN `lab` AS >> name2 ON ((lab.id = researcher_lab_permission.lab_**id) AND >> (lab.is_active = 'T')) >> >> Some JOINS are wrong >> >> >> 2013/10/29 Diogo Munaro <diogo....@gmail.com> >> >>> I need these joins because I need filter some tables without selecting >>> all the tables and filtering with where. Anyway, I tried: >>> >>> rows = (db.groups.id == db.lab.group_id)(db.lab.id == >>> db.researcher_lab_permission.l**ab_id)(db.researcher.id == >>> db.researcher_lab_permission.r**esearcher_id)(db.researcher.us**er_id == >>> db.auth_user.id).select(db.**groups.name <http://db.groups.name/>, >>> db.city.name,db.**auth_user.ALL) >>> >>> And it returns: >>> <type 'exceptions.TypeError'> 'Query' object is not callable >>> I'm using db.executesql and it's working: >>> >>> db.executesql('''SELECT l.id,g.name,c.name FROM >>> researcher_lab_permission as rl JOIN lab as l >>> JOIN researcher as r JOIN auth_user as a JOIN groups as >>> g JOIN city as c >>> ON rl.researcher_id = r.id AND rl.lab_id = l.id AND a.id= >>> r.user_id AND l.group_id = >>> g.id >>> AND c.id = g.city_id WHERE a.id = %s''' %(auth.user_id)) >>> >>> Something strange with DAL... >>> >>> 2013/10/28 Massimo Di Pierro <massimo....@gmail.com> >>> >>>> (db.groups.**id <http://db.groups.id/> == db.lab.group_id)(db.lab.id == >>>> db.researcher_lab_permission.**l**ab_id)(db.**researcher.id<http://db.researcher.id/> >>>> == db.researcher_lab_permission.**r**esearcher_id)(db.researcher.**us* >>>> *er_id == db.auth_user.id).select(db.**groups.name<http://db.groups.name/> >>>> ,db.**city.name <http://db.city.name/>,db.**auth_user.ALL) >>> >>> >>> >>> >> -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to a topic in the > Google Groups "web2py-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/web2py/0YdtJwCEdl4/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.