-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
LINQ/SQLITE: Unnecessary IS NULL term generated for linq clause !string.isnullorempty() #19410
Comments
/cc @maumar |
IsNullOrEmpty can never be null, so we shouldn't ally "full" expansion even for the negated case. Related to #18555. Irrespective, |
Problem here is that at the time we compute null semantics we have the expression in the following form: NOT ( v.Country IS NULL OR ( v.Country = N'' )) however we only recognize pattern is form: column IS NOT NULL && (...) We should recognize the pattern in the negated form as well, i.e. column IS NULL OR (...) |
note: on sqlserver we translate IsNullOrEmpty to like and don't produce the redundant null check: NOT ([c].[Country] IS NULL OR ([c].[Country] LIKE N'')) |
…at are guaranteed to be null and remove redundant IS NULL/ IS NOT NULL checks Adding a list of columns guaranteed to be null in the given subtree. When processing right side of the || operator, we can convert those to non-nullable columns and therefore improve the generated sql. Also added optimization for conditional - if the test has some columns guaranteed to be nullable, we can flip those also when processing the Else subtree. Also fixes #19410
…at are guaranteed to be null and remove redundant IS NULL/ IS NOT NULL checks Adding a list of columns guaranteed to be null in the given subtree. When processing right side of the || operator, we can convert those to non-nullable columns and therefore improve the generated sql. Also added optimization for conditional - if the test has some columns guaranteed to be nullable, we can flip those also when processing the Else subtree. Fixes #19883 Fixes #19410
…at are guaranteed to be null and remove redundant IS NULL/ IS NOT NULL checks Adding a list of columns guaranteed to be null in the given subtree. When processing right side of the || operator, we can convert those to non-nullable columns and therefore improve the generated sql. Also added optimization for conditional - if the test has some columns guaranteed to be nullable, we can flip those also when processing the Else subtree. Fixes #19883 Fixes #19410
…at are guaranteed to be null and remove redundant IS NULL/ IS NOT NULL checks Adding a list of columns guaranteed to be null in the given subtree. When processing right side of the || operator, we can convert those to non-nullable columns and therefore improve the generated sql. Also added optimization for conditional - if the test has some columns guaranteed to be nullable, we can flip those also when processing the Else subtree. Fixes #19883 Fixes #19410
…at are guaranteed to be null and remove redundant IS NULL/ IS NOT NULL checks Adding a list of columns guaranteed to be null in the given subtree. When processing right side of the || operator, we can convert those to non-nullable columns and therefore improve the generated sql. Fixes #19883 Fixes #19410
…at are guaranteed to be null and remove redundant IS NULL/ IS NOT NULL checks Adding a list of columns guaranteed to be null in the given subtree. When processing right side of the || operator, we can convert those to non-nullable columns and therefore improve the generated sql. Fixes #19883 Fixes #19410
Hi,
Using AspnetCore 3.1 with Linq/SQLite, I have a SQL strangely generated for a simple clause.
I have a simple table containing 2 text fields : COUNTRY and ISOCOUNTRY.
I want to get all rows where COUNTRY is not null and not empty:
When I look into the SQL generated for the Where(v => !string.IsNullOrEmpty(v.Country)) :
The Where clause should be like:
WHERE "v"."Country" IS NOT NULL AND "v"."Country" <> ''
Regards
The text was updated successfully, but these errors were encountered: