Filter returns empty datascource

I have a data source where I want every element in the database except two specific elements that are specified in a separate da source each. In my case one of the two “one” data sources does not have a value at the moment. When I apply the filter that should give me every element except the two, no elements is returned. Is this a bug?

Hi!

What is the cardinality of the right-side datasources? In order for this filter to make sense (using the Not equals operator) the datasources on the right side must be either cardinality One, or they must have a single selected object.

In any other case: use operator Is None Of.

The cardinality of both right side datasources are one.

In this case the database contains 6 entries of type “KP - Produktliste”
“KP-Produktliste (Aktiv)” Has cardinality one and contains one element.
“KP-Produktliste (Kommende)” Has cardinality one and contains no elements.
The filtered result contains no elements.

Hi,

I see. This behaviour has in fact been discussed years back, and was not concluded to be changed. The reason is that SQLs behave the same way, if the right-side return null/undefined.

Example:

SELECT * 
FROM tasks t
WHERE t.projectId <> (
    SELECT TOP 1 projectId 
    FROM projects 
    WHERE projectState = 0
);

If no record is returned in the subquery, the comparison towards null is not possible and there will be no tasks returned from the query.

Appfarm follows the same principle in this case, whether it is correct is a matter of opinion/definition. But, changing such behaviour may have major implications on business logic already defined with the current behaviour in mind.

So, you should change the business logic. For example: If you combine the right-side datasources into one (Aktive and Kommende), you can use operator Not exists in, which will produce a valid comparison.

1 Like