Question

I would like to do an Odata query where I filter on a Boolean column like this:

Example:

IsVisible != true (or IsVisible != false).

Now I know that in Odata this would be "IsVisible ne 'true'". If IsVisible happens to be null, then this "ne true" does not return null values of IsVisible (which is what I want). Instead it is just returning values for IsVisible == true.

I know that I can get the records that I want by doing something like this:

IsVisible == null (IsVisible eq 'null').

The question is this:

How can I make Odata return IsVisible == 'true' AND IsVisible == 'null' when I filter by IsVisible != false (IsVisible ne 'false')?

Was it helpful?

Solution

Looking at the tag you assigned to the question, I would point out that this is actually not boolean logic, but three-valued logic. Implementations of such models must necessarily make arbitrary choices regarding their constructs, and in the case of OData, it seems that "something that isn't false must be true".

I suppose this is in part because more people would be confused otherwise, and in part because most other implementations work that way too.

As far as I know, there is no shortcut for your use-case (you must check both conditions explicitly).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top