Question about a field boolean in MSSQL

47 views
Skip to first unread message

Gianganh Nguyen

unread,
Oct 24, 2014, 6:36:52 AM10/24/14
to web...@googlegroups.com

Hello to everybody,
I have a question, please answer for me!

In the model, I define a field:
db.define_table('mytable',
                          Field('is_imported', 'boolean', default = False), ...)
db.mytable.insert(is_imported = True,..)
db.mytable.insert(is_imported = False,..)

In the controller, I write:
records = db(db.mytable.id).select(db.mytable.is_imported)
for record in records:
    print record.is_imported

Result:
     False
     False

Expected result:
    True
     False

And I see with boolean fields, command select always return False for every values (0, 1) in mssql.
I were trying with all mssql and mssql2, they had same result.

Please tell me why.
Thanks.

Gianganh Nguyen

unread,
Oct 24, 2014, 7:14:47 AM10/24/14
to web...@googlegroups.com
Sorry, this issue just occur in mssql2.


Vào 17:36:52 UTC+7 Thứ sáu, ngày 24 tháng mười năm 2014, Gianganh Nguyen đã viết:

Anthony

unread,
Oct 24, 2014, 8:28:45 AM10/24/14
to web...@googlegroups.com
Looks like the MSSQL2 adapter stores booleans as "T" and "F" character values, so you may need to convert your 1's and 0's to "T" and "F".

Anthony

Gianganh Nguyen

unread,
Oct 26, 2014, 9:36:53 PM10/26/14
to web...@googlegroups.com
Oh, I understand. Thank you so much! :)

--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/eB0DFcfFjjY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Gianganhnguyen
CS - Soict - Hust - K52

Mobile: 0975814385

Tim Richardson

unread,
Nov 5, 2014, 6:15:48 AM11/5/14
to web...@googlegroups.com
And mssql3 uses 0 & 1 it seems.
Reply all
Reply to author
Forward
0 new messages