Good catch Anthony!

On Wednesday, 6 April 2016 13:35:39 UTC-5, Anthony wrote:
>
>     table = db.auth_user
>>     fields = ['id','first_name']
>>     fields.append('test_field_1')
>>     
>>     query = table.id > 0
>>     
>>     row = db(query).select(*fields).first().as_dict()
>>
>
> The problem is that you aren't passing the correct arguments to .select(). 
> You must pass Field objects, not simply the string names of the fields. So, 
> it should be:
>
>     db(query).select(*[table[f] for f in fields]).first().as_dict()
>
> Now you will get a Row object with all the usual keys/values at the top 
> level and no "_extra" sub-dictionary. In this case, the "T" and "F" values 
> will be translated properly to True and False because now .select() knows 
> the field types and does the proper parsing. When you simply pass field 
> names to .select(), it doesn't have any information about the Field objects 
> themselves -- it therefore doesn't know if a field is boolean and doesn't 
> make the translation from "T"/"F" to True/False.
>
> Anthony
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to