Another solution is to identify duplicate names and simply append numbers (e.g., id_1, id_2), but in most cases it would probably be preferable to directly specify the colnames. If we don't take that approach, it would probably be better to raise an exception when duplicate column names are encountered rather than the current behavior, which is clearly not desirable.
Anthony On Thursday, January 2, 2014 8:13:26 PM UTC-5, Anthony wrote: > > This may be tricky. In case of as_dict=True, executesql() uses the > adapter.cursor.description to get the column names, but there is no > indication which column name comes from which table, so if both tables have > the same column name, the dict will only get one of the columns. > executesql() does take a "colnames" argument, so you can instead supply the > column names directly, which is probably the best we can do in case of a > join. > > Anthony > > On Thursday, January 2, 2014 7:49:20 PM UTC-5, Massimo Di Pierro wrote: >> >> I think it is a bug. Please open a ticket linking this thread. >> >> On Thursday, 2 January 2014 13:20:04 UTC-6, ssuresh wrote: >>> >>> I found a peculiar problem when executing a join query on two tables. I >>> have two tables table1 and table2. Both have ids as their pks. table1 has a >>> FK on table2 using table2_id field. >>> >>> Now when i do an executesql of the following query, >>> >>> rows=executesql('select * from table1,table2 where table1.table2_id= >>> table2.id',as_dict=True) >>> >>> I always get only one id field in the return dict and I dont know >>> whether the id is of table1 or table2. >>> >>> Am I doing something wrong, or is it a possible bug? >>> >> -- 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.