Rows.as_dict default key

23 views
Skip to first unread message

Alan Etkin

unread,
Jan 13, 2013, 3:42:17 PM1/13/13
to web2py-d...@googlegroups.com
About http://code.google.com/p/web2py/issues/detail?id=1273

I sent a patch to Massimo, but I belive it should be improved.

The problem occurs when you  call .as_dict() (without specifying a key)  in a Rows instance (with join results). The object cannot guess a default key for creating the dictionary, so it defaults to "id" and produces a KeyError. My patch looks for an .id column trough the results set, but this will work for only generic .select() commands and will fail in other cases.

Could we use, for example, generic integers for each result in this case? Or it's better to leave the current behavior, raising an error if no valid key was passed?
Reply all
Reply to author
Forward
0 new messages