thanks,
I'll santinize the database onec a while.
cheers,
Stef
On 19-01-14 13:45, Niphlod wrote:
or, if indeed you want all strings fields with NULL values (backends
side) or "None" (python side) to map to an empty string '', use
none_value = None
for f in db.table.fields:
if db.table[f].type == 'string':
db(db.table[f] == None).update(f='')
On Sunday, January 19, 2014 3:21:49 AM UTC+1, Anthony wrote:
but I mean the field is empty / Null / None (type),
which is translated by web2py into a string value 'None'.
None is translated into a string value as 'None' by Python, not
web2py. If you want different behavior, you have to be explicit
(no reason to assume the default behavior should be an empty
string). You can achieve that by setting the represent attribute
of the field:
|
Field('myfield',represent=lambdav,r:''ifv isNoneelsev)
|
or more simply:
|
Field('myfield',map_none='')
|
Those methods will work in the grid and SQLFORMs, but not if you
simply do {{=row.myfield}} somewhere. In that case, you would have
to do something like {{=row.myfield or ''}}, or use the
Rows.render() method to extract the row, which will automatically
apply the "represent" function -- {{=rows.render(0).myfield}}.
Anthony
--
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/groups/opt_out.
--
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/groups/opt_out.