# 1. Create table
db.define_table('tablita',
Field('aa','double'),
Field('bb','double'),
Field('cc','double', compute=lambda r: r['aa']+r['bb']), migrate=True
)
# 2. Add record with appadmin.py
aa=1
bb=2
# Result cc=3 that's correct
# 3. But in controller
def suma():
suma = db(db.tablita.id==1).select().first()
suma.update_record(aa=2)
print suma ## <Row {'aa': 2, 'bb': 2.0, 'cc': 3.0, 'id': 1L}>
## is wrong, that no update computed fields, cc is still 3 when it should be 4
message = 'Hello'
return dict(message=message)
# What is the expected output?
cc=4
# What do you see instead?
cc=3
suma.update_record(aa=2, bb=suma.bb)
I found this report in the bug tracker, and I've had a similar problem:
# 1. Create table
db.define_table('tablita',
Field('aa','double'),
Field('bb','double'),
Field('cc','double', compute=lambda r: r['aa']+r['bb']), migrate=True
)
# 2. Add record with appadmin.py
aa=1
bb=2
# Result cc=3 that's correct
# 3. But in controller
def suma():
suma = db(db.tablita.id==1).select().first()
suma.update_record(aa=2)
print suma ## <Row {'aa': 2, 'bb': 2.0, 'cc': 3.0, 'id': 1L}>
## is wrong, that no update computed fields, cc is still 3 when it should be 4
message = 'Hello'
return dict(message=message)
# What is the expected output?
cc=4
# What do you see instead?
cc=3
Basically, every time I use one of my database tables, I'm surprised because the computation fails silently, so I don't know the computed field is going to be out of sync. I finally realized that the silence was causing me to overlook an important class of errors, and added required=True to every computed field.I'm not sure what the best way to handle this is (include all the fields in the update? make computed fields not have a default value for required?) but I just thought I'd +1 this issue and say I'd love any fixes/upgrades!Thanks.--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-d...@googlegroups.com
unsubscribe: web2py-develop...@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-develop...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
True. Hidden queries would also be suboptimal. I think if I had some warning that my computed fields were failing on me that'd be enough - I suspect there are other people who have run into this issue.Any way the update_record can be used on SQLFORM?
form = SQLFORM(db.page, page_selected(), fields=['text'])
if form.accepts(request.vars, session):
To unsubscribe from this group and stop receiving emails from it, send an email toweb2py-developers+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email toweb2py-develop...@googlegroups.com.
request.vars.myothervar = form.vars.myothervar = ‘somevalue'
To unsubscribe from this group and stop receiving emails from it, send an emailtoweb2py-developers+unsubscr...@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-d...@googlegroups.com
unsubscribe: web2py-develop...@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email toweb2py-developers+unsub...@googlegroups.com.
Was this added before or after 2.7.5? I'm using the exact code below on one string field and one int field (tied to an id in another table), and gluon/html.py/FORM.accepts() is giving a 'value not found in database' error for the int.
To unsubscribe from this group and stop receiving emails from it, send an emailtoweb2py-developers+unsubscr...@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-d...@googlegroups.com
unsubscribe: web2py-develop...@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email toweb2py-developers+unsub...@googlegroups.com.
--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-d...@googlegroups.com
unsubscribe: web2py-develop...@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.