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

GroupBy Bool adds "= 1 = 1" to the Generated SQL #15103

Closed
SniperED007 opened this issue Mar 21, 2019 · 0 comments · Fixed by #18283
Closed

GroupBy Bool adds "= 1 = 1" to the Generated SQL #15103

SniperED007 opened this issue Mar 21, 2019 · 0 comments · Fixed by #18283
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Milestone

Comments

@SniperED007
Copy link

Describe what is not working as expected.

When including a GroupBy column that is a Bool it adds a "= 1 = 1" after the Bool column in the Group By clause to the generated SQL (i.e. [x.Location].[IsOcean] = 1 = 1). Should not have the "=1 =1" at all.

          var locations = await _context.tb_ChallengeAttempt
          .Include(x => x.Location)
          .GroupBy(t => new
          {
            t.Location.IsOcean,
            t.Location.CountryCode
          })
          .Select(s => new
          {
            s.Key.IsOcean,
            CountryCode = s.Key.CountryCode.ToLower()
          })
          .ToListAsync();
SELECT [x.Location].[IsOcean], LOWER([x.Location].[CountryCode]) AS [CountryCode]
FROM [tb_ChallengeAttempt] AS [x]
LEFT JOIN [tb_Location] AS [x.Location] ON [x].[LocationId] = [x.Location].[Id]
GROUP BY [x.Location].[IsOcean] = 1 = 1, [x.Location].[CountryCode]
Exception message:

System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near '='.
   at System.Data.SqlClient.SqlCommand.<>c.<ExecuteDbDataReaderAsync>b__122_0(Task`1 result)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues, CancellationToken cancellationToken)
ClientConnectionId:36989bed-2396-454f-802a-43dd79549df3
Error Number:102,State:1,Class:15

Further technical details

EF Core version: Microsoft.EntityFrameworkCore.SqlServer 2.2.3
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10
IDE: Visual Studio 2017

@SniperED007 SniperED007 changed the title GroupBy Boolean GroupBy Bool adds "= 1 = 1" to the Generated SQL Mar 21, 2019
@ajcvickers ajcvickers added this to the 3.0.0 milestone Mar 22, 2019
@divega divega modified the milestones: 3.0.0, Backlog Jun 21, 2019
@smitpatel smitpatel removed their assignment Jun 24, 2019
@smitpatel smitpatel added the verify-fixed This issue is likely fixed in new query pipeline. label Jul 2, 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 punted-for-3.0 verify-fixed This issue is likely fixed in new query pipeline. labels Oct 8, 2019
@maumar maumar modified the milestones: 3.1.0, 3.0.0 Oct 8, 2019
maumar added a commit that referenced this issue Oct 8, 2019
- added regression tests for #12289
- added regression tests for #15279
- added regression tests for #15938
- added regression tests for #18267

- resolves #12522
- resolves #12805
- resolves #13231
- resolves #13594
- resolves #13754
- resolves #14851
- resolves #15103
- resolves #15669
- resolves #15853
maumar added a commit that referenced this issue Oct 8, 2019
- added regression tests for #12289
- added regression tests for #15279
- added regression tests for #15938
- added regression tests for #18267

- resolves #12522
- resolves #12805
- resolves #13231
- resolves #13594
- resolves #13754
- resolves #14851
- resolves #15103
- resolves #15669
- resolves #15853
maumar added a commit that referenced this issue Oct 8, 2019
- added regression tests for #12289
- added regression tests for #15279
- added regression tests for #15938
- added regression tests for #18267

- resolves #12522
- resolves #12805
- resolves #13231
- resolves #13594
- resolves #13754
- resolves #14851
- resolves #15103
- resolves #15669
- resolves #15853
maumar added a commit that referenced this issue Oct 8, 2019
- added regression tests for #12289
- added regression tests for #15279
- added regression tests for #15938
- added regression tests for #18267

- resolves #12522
- resolves #12805
- resolves #13231
- resolves #13594
- resolves #13754
- resolves #14851
- resolves #15103
- resolves #15669
- resolves #15853
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 type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants