- changed milestone to 0.5.xx
result_processor for SLBoolean should check if value equals to 1
Issue #1402
resolved
Firstly, some queries with sqlite
sqlite> create table test (boo boolean not null);
sqlite> insert into test values ('false');
sqlite> insert into test values ('true');
sqlite> insert into test values ('0');
sqlite> insert into test values ('1');
sqlite> insert into test values (0);
sqlite> insert into test values (1);
sqlite> select * from test where boo;
1
1
sqlite> select * from test where not boo;
false
true
0
0
Only 1 evaluates to true.
However, when it get to SA, 1, false, and true all evaluate to true, due to this line in the result_processor method of the sqlite driver:
return value and True or False
since * 1 and True or False => True * 'false' and True or False => True * 'true' and True or False => True
Although the bind_processor does ensure that only 1 and 0 get stored, we may still have data inserted into the db through something other than SA. Then, these data will come up wrongly in SA.
A simple fix is to only return True if the value equals to 1, i.e.
return value == 1 and True or False
Comments (4)
-
repo owner -
Corrected in 01cdbd073469240065dc0f5c224eaf90f4e113ac.
-
Account Deleted Hehe. Thanks for the quick fix.
-
repo owner - removed milestone
Removing milestone: 0.5.4 (automated comment)
- Log in to comment
how about
return value == 1