Hi Massimo, Same problem exists in SQLserver (not surprising, uses the same code). I think that arguably the best solution would be to change the current JOIN X,Y ... WHERE [join condition] into X INNER JOIN Y ON [join condition]. That would be a bigger patch...
For now I've used the patch by Alexey successfully (stripped of the full_table_name function, as suggested). I don't know if he has send you the patch already but I'll send it by separate mail. I'll test it further. Nico de Groot On 11 mei, 16:27, mdipierro <[email protected]> wrote: > Thank you. will look into it. > > Massimo > > On May 11, 6:31 am, Alexey Nezhdanov <[email protected]> wrote: > > > > > Hi. > > I've come across another subtle problem with web2py's DAL running over IBM > > DB2 database. > > DB2 requires thelefttable to immidiatedly preceed the 'leftouterjoin' > > keyword. > > IOW: > > select * from a, bleftouterjoinc on c.a_id=a.id > > is incorrect. Correct form is: > > select * from b, aleftouterjoinc on c.a_id=a.id > > it looks moronish enough, but alas, we have to live with it. > > > I have modified my local copy of web2py to satisfy this requirement. > > Please note that this sample can not be copypasted into web2py's sql.py as > > is because of full_table_name wrapper that I added to solve another problem > > - schemas support. But replacing 'full_table_name(db, t)' with just 't' > > should work just fine. > > > join= attributes['left'] > > command = self._db._translator['leftjoin'] > > if not isinstance(join, (tuple, list)): > > join= [join] > > joint = [t._tablename for t injoinif not isinstance(t, > > SQLJoin)] > > joinon = [t for t injoinif isinstance(t, SQLJoin)] > > tables_to_merge={} > > > [tables_to_merge.update(dict.fromkeys(parse_tablenames(str(t.query)))) for t > > in joinon] > > joinont = [t.table._tablename for t in joinon] > > [tables_to_merge.pop(t) for t in joinont if t in > > tables_to_merge] > > important_tablenames = joint + joinont + tables_to_merge.keys() > > excluded = [t for t in tablenames if not t in > > important_tablenames ] > > sql_t = ', '.join([full_table_name(self._db, t) for t in > > excluded + tables_to_merge.keys()]) > > if joint: > > sql_t += ' %s %s' % (command, ', > > '.join([full_table_name(self._db, t) for t in joint])) > > for t in joinon: > > sql_t += ' %s %s' % (command, str(t)) > > > Regards > > Alexey- Tekst uit oorspronkelijk bericht niet weergeven - > > - Tekst uit oorspronkelijk bericht weergeven -

