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

Query: Subquery comparison to null is translated incorrectly #6353

Closed
shaulbehr opened this issue Aug 18, 2016 · 1 comment
Closed

Query: Subquery comparison to null is translated incorrectly #6353

shaulbehr opened this issue Aug 18, 2016 · 1 comment
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@shaulbehr
Copy link

The following query:

                        thoughts = from t in thoughts
                                   let recentCommentUserId = t.ThoughtComments
                                                              .OrderByDescending(c => c.DateTime)
                                                              .Select(c => (Guid?)c.UserId)
                                                              .FirstOrDefault()
                                   where t.UserId != teacherUser.UserId
                                         && (recentCommentUserId == null || recentCommentUserId != teacherUser.UserId)
                                   select t;

translates to:

exec sp_executesql N'SELECT COUNT(*)
FROM [dbo].[Thought] AS [t]
WHERE ([t].[ClassId] = @__criteria_ClassId_Value_0) AND (([t].[UserId] <> @__teacherUser_UserId_1) AND (((
    SELECT TOP(1) [c].[UserId]
    FROM [dbo].[ThoughtComment] AS [c]
    WHERE [t].[ThoughtId] = [c].[ThoughtId]
    ORDER BY [c].[DateTime] DESC
) = NULL) OR ((
    SELECT TOP(1) [c0].[UserId]
    FROM [dbo].[ThoughtComment] AS [c0]
    WHERE [t].[ThoughtId] = [c0].[ThoughtId]
    ORDER BY [c0].[DateTime] DESC
) <> @__teacherUser_UserId_2)))',N'@__criteria_ClassId_Value_0 uniqueidentifier,@__teacherUser_UserId_1 uniqueidentifier,@__teacherUser_UserId_2 uniqueidentifier',@__criteria_ClassId_Value_0='3B7EC359-E000-45D6-A1ED-08D3C74419A2',@__teacherUser_UserId_1='2D1F3B39-5333-4748-FB49-08D3C74418C2',@__teacherUser_UserId_2='2D1F3B39-5333-4748-FB49-08D3C74418C2'

Notice the comparison "= NULL". That doesn't work. It should be 'IS NULL'

@divega divega added this to the 1.1.0 milestone Aug 19, 2016
@maumar maumar modified the milestones: 1.1.0, 1.1.0-preview1 Oct 5, 2016
@rowanmiller rowanmiller modified the milestones: 1.1.0, 1.2.0 Oct 17, 2016
@maumar maumar assigned smitpatel and unassigned maumar Apr 13, 2017
@smitpatel
Copy link
Member

This is probably fixed by #7950

@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Apr 18, 2017
@ajcvickers ajcvickers modified the milestones: 2.0.0-preview1, 2.0.0 Apr 19, 2017
@smitpatel smitpatel modified the milestones: 2.0.0-preview1, 2.0.0 Apr 20, 2017
@ajcvickers ajcvickers changed the title Comparison to null is translated incorrectly Query: Comparison to null is translated incorrectly May 9, 2017
@smitpatel smitpatel changed the title Query: Comparison to null is translated incorrectly Query: Subquery comparison to null is translated incorrectly May 9, 2017
@divega divega added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels May 10, 2017
@ajcvickers ajcvickers modified the milestones: 2.0.0-preview1, 2.0.0 Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

6 participants