Skip to content

Parentheses put around IS NULL only if operand is of type boolean (6.0) #26652

@roji

Description

@roji

#25722 fixed #23990 by adding parentheses around IS NULL/IS NOT NULL, preventing operator precedence issues. However, it did so only when the operand of IS NULL is a bool. However, the same problem can happen if a non-bool column is being checked for null.

See npgsql/efcore.pg#2090 on PostgreSQL where the following LINQ query:

var boolParam = true;
_ = ctx.Blogs.Where(c => boolParam != c.NullableGuid.HasValue).ToList();

... generates the following SQL ...

SELECT b."Id", b."NullableGuid"
FROM "Blogs" AS b
WHERE @__boolParam_0 <> b."NullableGuid" IS NOT NULL

... which fails with operator does not exist: boolean <> uuid, because in PostgreSQL the precedence of <> is higher than the precedence of IS NOT NULL (docs). The issue also causes wrong data to be returned in Sqlite.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions