-
Notifications
You must be signed in to change notification settings - Fork 256
Milestone
Description
Hi
The Model looks something like this:
public class MyClass {
public Guid Id {get;set;}
public Guid? ParentId {get;set;}
}
then the query:
var valueFilterNegated = true;
... // some logic to set the valueFilterNegated
dbContext.MyClasses.Where(c =>valueFilter != c.ParentId.HasValue).CountAsync(cancellationToken);
the SQL Query produced is:
SELECT COUNT(*)::INT
FROM "MyClasses" AS s
WHERE ($1 <> s."ParentId" IS NOT NULL)
with $1 being either True or False, depending on the valueFilterNegated.
The Problem is, that the <> operator has a stronger binding than the IS NOT NULL and therefore it tries to compare boolean <> guid which throws: operator does not exist: boolean <> uuid at character
The solution is quite simple, put parantheses:
SELECT COUNT(*)::INT
FROM "MyClasses" AS s
WHERE ($1 <> (s."ParentId" IS NOT NULL))
Reactions are currently unavailable