I had some difficult time with handling boolean values from MySQL.

When I define a table with *db.define_table* and in the Field constructor 
define *type='boolean'*, the column in the data base becomes a *char(1)*. 
Values 
are "*T*" of "*F*".

Now when I do a query/select and iterate through the rows, and do  *x = 
row.column_name* I receive an *x* value of type <type 'str'> Values are "*T*" 
of "*F*".


However, if I do a direct *record = db.table[id]*, and then *x = 
record['column_name']* , my *x* variable becomes of type <type 'bool'> Values 
are *True* or *False*.


Obviously, my code that was trying to do *if x:* was behaving quite 
differently depending on the way the value was retrieved.


My eventual fix was to check if *x* was True or "T".


Is this a bug or a feature, or what is it I did wrong?

-- 
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