Better management of negated expressions #31027
Labels
area-query
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
type-cleanup
type-enhancement
Milestone
For EXISTS, IN and SQLite glob and regexp, we support a nicer negated SQL: instead of
NOT (x IN y)
, we generatex NOT IN y
.However, this is implemented by having an IsNegated flag on the expression node itself; this forces us to check and deal with the possible negation in various visitors across the query pipeline (e.g. null semantics), to optimize NOT(EXISTS) to the negated EXISTS form, etc. This introduces needless complexity - we can simply have these nodes wrapped in a NOT SqlUnaryExpression nodes as with all other expressions, recognize them in QuerySqlGenerator instead and generate the nicer SQL.
As a bonus, this PR generates nicer negated SQL for LIKE as well (i.e.
x NOT LIKE y
instead ofNOT (x LIKE y)
.The text was updated successfully, but these errors were encountered: