I never updated data this way before, and after having made some tests, it 
turns out that db.table.lft type is a Field that is converted into a string 
and then an integer later (I don't know how).

And I try the example from the book 
db(db.table.lft>0).update(lft=db.table.lft+1) appends the string '1' to the 
value (casted to string) of db.table.lft (this seems very weird to me 
because db.table.lft type is Field)

For example if db.table.lft (Field, type int) row value is 12345, 
db.table.lft+1 after db update will give 123451

Or am I missing something ?


On Wednesday, May 28, 2014 8:21:56 AM UTC, Marian wrote:
>
> I want to negate a value with this expression:
>
> db(db.table.lft > 0).update(lft = 0 - db.table.lft)
>
> but I get the following TypeError:
> TypeError: unsupported operand type(s) for -: 'int' and 'Field'
>
> My workaround is:
> db(db.table.lft > 0).update(lft = db.table.lft - db.table.lft - db.table.lft)
>
>
> *It seems that update expression need to start with the field or do I miss 
> something?*
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to