[Qt-interest] Comparing two NULL QVariants returns true

Andre Somers andre at familiesomers.nl
Mon May 30 20:41:42 CEST 2011


Op 30-5-2011 19:16, Israel Brewster schreef:
> I want to say that I've seen it for a number of databases. It does sound somewhat counterintuitive on the face of things, but it starts making sense when you take database restrictions into account. Say, for example, that you have a database of office workers with a phone number column. No two people can have the same phone number (we're assuming people don't share phones), but some people may not have a phone number at all. If null was considered equal, and you put a unique constraint on the phone column, then only one person would be allowed to have no phone. With null not being equal, the unique constraint works as expected- you can have any number of people without phone numbers, but no two people can have the SAME phone number. So from that perspective it makes sense for comparing two null values to return false.
>
I understand your point, but I just wanted to point out that the 
assumption that no two employees can have the same phone number is 
obviously false. I happen to work in a place where we have a married 
couple on the work floor, and I image that situation to happen more 
often :-)

André




More information about the Qt-interest-old mailing list