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

EF Core 2.2.1 update from 2.1, undeclared scalar variable name. #14550

Closed
wasabii opened this issue Jan 30, 2019 · 1 comment · Fixed by #18193
Closed

EF Core 2.2.1 update from 2.1, undeclared scalar variable name. #14550

wasabii opened this issue Jan 30, 2019 · 1 comment · Fixed by #18193
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported regression type-bug
Milestone

Comments

@wasabii
Copy link

wasabii commented Jan 30, 2019

System.Data.SqlClient.SqlException: The variable name '@__courtCase_Court_Organization_0_Id' has already been declared. Variable names must be unique within a query batch or stored procedure.
Must declare the scalar variable "@__efmJudge_EfmId_3".

This seems to happen in a block of code that looks like this:

            var ca = jcmsDb.CerberusUsers
                .Where(i => i.Organization == courtCase.Court.Organization)
                .Distinct()
                .Where(i => ut.Contains(i.UserType))
                .Where(i => i.Organization == courtCase.Court.Organization)
                .OrderBy(i => i.UniqueId)
                .Where(i => !exclude.Contains(i));

EF Core 2.1 worked fine. Upon upgrading to 2.2, this began breaking. Yes, that's clearly a dumb query. Upon removing the duplicate Where expression, it works fine. Still, a regression, and a bug, somewhere.

@vassilvk
Copy link

vassilvk commented Apr 10, 2019

The same issue can be observed in valid cases where the same variable is used multiple times in a Where call.

For example:

...
.Where(i =>
  i.Organization == courtCase.Court.Organization
  || i.OtherOrganization == courtCase.Court.Organization)
...

@ajcvickers ajcvickers modified the milestones: 3.0.0, Backlog Jul 24, 2019
@ajcvickers ajcvickers added punted-for-3.0 verify-fixed This issue is likely fixed in new query pipeline. labels Jul 24, 2019
@smitpatel smitpatel removed the query label Sep 3, 2019
@ajcvickers ajcvickers modified the milestones: Backlog, 3.1.0 Sep 4, 2019
@maumar maumar added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed verify-fixed This issue is likely fixed in new query pipeline. labels Oct 2, 2019
maumar added a commit that referenced this issue Oct 2, 2019
resolves #14550
resolves #15164
resolves #15994

added regression tests for #14671
added regression test for #17852
converted remaining tests in Gears of War into AssertQuery pattern (part of #12501)
maumar added a commit that referenced this issue Oct 2, 2019
resolves #14550
resolves #15164
resolves #15994

added regression tests for #14671
added regression test for #17852
converted remaining tests in Gears of War into AssertQuery pattern (part of #12501)
@maumar maumar closed this as completed in 1bd4e85 Oct 3, 2019
@maumar maumar modified the milestones: 3.1.0, 3.0.0 Oct 3, 2019
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. customer-reported regression type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants