Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better management of negated expressions #31027

Closed
roji opened this issue Jun 4, 2023 · 0 comments · Fixed by #31028
Closed

Better management of negated expressions #31027

roji opened this issue Jun 4, 2023 · 0 comments · Fixed by #31028
Assignees
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

Comments

@roji
Copy link
Member

roji commented Jun 4, 2023

For EXISTS, IN and SQLite glob and regexp, we support a nicer negated SQL: instead of NOT (x IN y), we generate x 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 of NOT (x LIKE y).

@roji roji self-assigned this Jun 4, 2023
@roji roji added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Jun 4, 2023
@roji roji modified the milestone: 8.0.0 Jun 4, 2023
roji added a commit to roji/efcore that referenced this issue Jun 4, 2023
roji added a commit to roji/efcore that referenced this issue Jun 4, 2023
roji added a commit to roji/efcore that referenced this issue Jun 4, 2023
roji added a commit to roji/efcore that referenced this issue Jun 5, 2023
roji added a commit to roji/efcore that referenced this issue Jun 5, 2023
roji added a commit to roji/efcore that referenced this issue Jun 5, 2023
roji added a commit that referenced this issue Jun 5, 2023
@ajcvickers ajcvickers added this to the 8.0.0-preview7 milestone Oct 11, 2023
@ajcvickers ajcvickers modified the milestones: 8.0.0-preview7, 8.0.0 Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants