Page 1 of 1

Linq where condition, filter ignored

Posted: Wed 12 Apr 2017 08:22
by rbeeston
Hello,
I am using EntityDAC and UniDAC against a postgresql database.
I have some user defined filters, i.e. users can choose when/what they are filtering.
To make things simple i define all filters initially as

FilterA := 1=1

So that its a valid expression and i can have a single where clause all the time.

.Where(FilterA and FilterB and FilterC....)

That's been working fine up until now, i want to be able to effectively ignore all the rows from the query by making a filter.

FilterZ := 1=2

Which is obviously false in all cases, thus should mean the query never returns any results. (Yes i could refactor my code not to bother running the query but its neater and simpler just to follow the same path and have no results)

This doesn't work, all the rows are returned, the "False" filter is being completely ignored.. why?

I deliberately broke the query so i could check what is actually being executed. Example screen shots attached. (Ignore the IGNORE=ME filter, that's me deliberately breaking the query, with this removed the query runs fine but produces results when it shouldn't)

Image
Imageimage upload no registration

Now i can work around this, but i'm very concerned, if my filter isn't being applied then what's to stop all the other filters being ignored too?!?!?! How can i trust the results!

Thanks

Re: Linq where condition, filter ignored

Posted: Wed 12 Apr 2017 12:53
by MaximG
Thank you for the information. We have reproduced the problem and fixed the bug. The fix will be included in the next EntityDAC build. We are planning EntityDAC release with RAD Studio Delphi 10.2 Tokyo support next week