Hi,
The following works
db=DAL('sqlite:memory')
db.define_table('tt',
Field('vv', 'integer'),
Field.Virtual('x', lambda row: row.tt.vv * 10))
db.tt.insert(vv='1')
print db(db.tt).select().first()
printing
<Row {'x': 10L, 'id': 1L, 'vv': 1L}>
We need more details to understand what is failing in your case. Can you
post a failing example?
Paolo
On Saturday, June 6, 2015 at 10:23:59 PM UTC+2, Donatas Burba wrote:
>
> Hello everybody. I am testing my products on web2py v2.11.2 base and have
> error. I want to ask is it new feature that virtual fields no more exist in
> Row after select? It means if I have Field.Virtual('x', ...) in my model,
> after doing db(db.tablename).select() I had this 'x' in results (with
> web2py v2.10.4), but now it is missing and my code, that depends on virtual
> field, just breaks.
> And secondly, why aren't "funny" names not allowed in field names? In
> search forms I am using one serializeJSON library (for serializing form and
> making ajax call) so for multiselects I must use names like 'classes[]' in
> order it would be serialized as array. But this is minor problem for me, I
> have a workaround already.
>
--
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.