Hi Web2py
I hope someone can explains this puzzling behavior. The code below was
taken from the book, and it works as given, but when I remove the
"yes_or_no" condition from the field list parameters it causes
a KeyError('id') error, and I don't understand why.
* condition = db.person.name.startswith('B')*
* yes_or_no = condition.case('Yes', 'No')*
* rows = db(db.person.name == 'Bob').select(db.person.name,yes_or_no
).as_dict() *
* rows = db(db.person.name == 'Bob').select(db.person.ALL).as_dict() *
* ## the two select examples above works as expected*
* rows = db(db.person.name == 'Bob').select(db.person.name).as_dict() *
This last example in red throws a KeyError('id') error when trying to name
specific fields, but works fine when returning ALL fields, or when a
condition is specified.
Thank you
-Rob
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/76104bd4-5469-47ae-8f2a-44698510cf2en%40googlegroups.com.