Boolean field nullable problem

jda jda at his.com
Tue Jul 21 07:51:57 CDT 2015


> On Jul 21, 2015, at 2:12 AM, Ivan Smahin <ivan_smahin at paradigmasoft.com> wrote:
> 
> Hi Jon,
> 
>> On Jul 20, 2015, at 11:25 PM, jda <jda at his.com> wrote:
>> 
>> Hi Ruslan,
>> 
>> I just upgraded from 5.5.2 to the current release (5.8.6 I think) and of course it broke some of my code.
>> 
>> I have a boolean field that I add to the database like this
>> 
>>    ALTER TABLE bibAndDoc ADD forCitation Boolean
>> 
>> In the past I’ve done queries for “forCitation=false”. Worked fine.
>> 
>> But in 5.8.6 these queries return nothing. I look in Valentina Studio and see that this is a nullable field. If I search for IS NULL I get hits. Is this a bug? I don’t want the field to be nullable (it’s a boolean). And if it is for some reason, I want the search for FALSE to find fields that are not TRUE. This is how it always worked.
>> 
>> Is this a bug I should report. I don’t want to change my searches to look for NULL or false…
>> 
> 
> Indeed, a long time any boolean field was not nullable always. But we consider it is wrong because NULL is sort of "unknown" value - it differs from true or false. If you need true/false values only you should make that field "not nullable". Something like this:
> 
> ALTER TABLE t1 ADD f1 Boolean NOT NULL;
> 

Hi Ivan,

I can do that, but now I have to update hundreds of older databases to set .isnullable = false for all my boolean fields! This could break a lot of code.

Letting the user set a boolean fields to nullable is fine, but I really think it should be NOT NULLABLE by default. The law of least astonishment says that if I create a boolean field I should be able to do a search on TRUE/FALSE. But now in Valentina you can’t unless you explicitly set the field to NOT NULLABLE on creation (and I’m guessing most people aren’t going to know that). If you just create a new boolean field now and don’t explicitly set it to true or false, searching for “false” always returns an empty cursor becuase it’s not “false”, it’s “null”.

BTW, it behaved that way at least through 5.5.2 (which was only 1.5 years old, January 2014). So the behavior change is relatively recent. I have to say this is one reason I only upgrade Valentina when I ablsolutely have to. So many upgrade break existing behavior!

Jon


More information about the Valentina mailing list