[web2py] Re: Issue with query with join and id in select field list

2017-10-12 Thread Anthony
On Thursday, October 12, 2017 at 12:45:05 PM UTC-4, Ricardo Oliveira wrote: > > Hi Anthony, > > Thanks for your excellent example and explanation. > You're right about the problem with the field names, luckily the problem > occurs only in this example, not in production code, but just out of > cu

[web2py] Re: Issue with query with join and id in select field list

2017-10-12 Thread Ricardo Oliveira
Hi Anthony, Thanks for your excellent example and explanation. You're right about the problem with the field names, luckily the problem occurs only in this example, not in production code, but just out of curiosity, would using "with_alias()" help? Thanks again for all your help. It made a huge

[web2py] Re: Issue with query with join and id in select field list

2017-10-12 Thread Anthony
You can call .as_dict() on a row object inside an iteration through .render(). Here is a one-liner to replace all your code: json.dumps(dict(data=[{k: v for sub_row in row.as_dict().values() for (k, v) in sub_row.iteritems()} for row in persons.render()])) The list compreh

[web2py] Re: Issue with query with join and id in select field list

2017-10-12 Thread Ricardo Oliveira
Hi Anthony, Thanks for your reply. That was also my initial solution. Problem is I need to use render() in order to force the lambdas of the table fields to be executed, and I can't seem to find a way to combine render() and as_dict(), that's why I used the approach of iterating through the Row

[web2py] Re: Issue with query with join and id in select field list

2017-10-11 Thread Anthony
The problem is here: > for field in person[table]: > person[table] is a Row object, and when the Row object includes the record ID, it also includes the special .update_record and .delete_record attributes. So, you'll either have to specify the fields explicitly, or check the typ