Haven't tested it, but looks good. I left a comment on github suggesting a more helpful error message.
Anthony On Friday, January 3, 2014 11:01:19 PM UTC-5, Massimo Di Pierro wrote: > > OK. Done. Please check it. > > On Friday, 3 January 2014 20:54:02 UTC-6, Anthony wrote: >> >> I agree. Because executesql() can execute any arbitrary SQL, it can't >> know how to properly name the columns, so the best approach when there are >> duplicate column names is probably just to require explicit specification >> via the "colnames" argument. >> >> Anthony >> >> On Friday, January 3, 2014 9:18:53 PM UTC-5, Massimo Di Pierro wrote: >>> >>> I think if there is a duplicated entry, and as_dict=True we should raise >>> an exception and explain the reasons. Unless there is a way to make this >>> this not ambiguous. >>> >>> >>> On Thursday, 2 January 2014 19:13:26 UTC-6, 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.