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

Bug with Take() #24726

Closed
vvwvann opened this issue Apr 22, 2021 · 3 comments
Closed

Bug with Take() #24726

vvwvann opened this issue Apr 22, 2021 · 3 comments
Assignees
Labels
area-query 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

@vvwvann
Copy link

vvwvann commented Apr 22, 2021

I encountered a situation when Take() throws an exception, in a simple code. I assume that this is a bug.

Npgsql.EntityFrameworkCore.PostgreSQL: "5.0.5.1"

            var result = await _context.Categories
                .AsNoTracking()
                .Include(x => x.Products.OrderByDescending(x => x.Discount).Take(4))
                    .ThenInclude(x => x.Preview)
                .OrderBy(x => x.Id)
                .Take(5)
                .ToListAsync();

This code throws an exception with next data

Severity: ERROR
SqlState: 42703
MessageText: column t.PreviewId doesn't exist
Hint: Perhaps a reference to the column was intended "t0.PreviewId".
Position: 3397
File: d:\pginstaller_12.auto\postgres.windows-x64\src\backend\parser\parse_relation.c
Line: 3359
Routine: errorMissingColumn

----------------------------------

Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.Exception: error
       ---> Npgsql.PostgresException (0x80004005): 42703: column t.PreviewId doesn't exist

I did not copy the entire stacktrace I think it is not very useful.

It seems to me that I have encountered a bug, since if you remove Take(5) everything will work fine:

            var result = await _context.Categories
                .AsNoTracking()
                .Include(x => x.Products.OrderByDescending(x => x.Discount).Take(4))
                    .ThenInclude(x => x.Preview)
                .OrderBy(x => x.Id)
                .ToListAsync();

I can provide more information if needed.

@smitpatel
Copy link
Contributor

Likely fixed in 6.0

@vvwvann
Copy link
Author

vvwvann commented Apr 22, 2021

Likely fixed in 6.0

What should I do to solve the problem now? Could you please provide a workaround?

@maumar maumar self-assigned this Apr 23, 2021
maumar added a commit that referenced this issue Apr 27, 2021
Issue has already been fixed by earlier query pipeline refactoring, adding regression tests
@maumar
Copy link
Contributor

maumar commented Apr 27, 2021

I have verified this bug is fixed in current bits. @vvwvann unfortunately there is no good workaround in 5.0. You need to remove the Take on the top level and filter the results on the client.

@maumar maumar closed this as completed Apr 27, 2021
@maumar maumar added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Apr 27, 2021
@maumar maumar added this to the 6.0.0 milestone Apr 27, 2021
maumar added a commit that referenced this issue Apr 27, 2021
Issue has already been fixed by earlier query pipeline refactoring, adding regression tests
ghost pushed a commit that referenced this issue Apr 27, 2021
Issue has already been fixed by earlier query pipeline refactoring, adding regression tests
@ajcvickers ajcvickers modified the milestones: 6.0.0, 6.0.0-preview5 May 27, 2021
haydenmc added a commit to Purdue-io/PurdueApi that referenced this issue Oct 5, 2021
This change removes the limit on query results due to an EF bug dotnet/efcore#24726 . This bug is fixed in .NET 6.

Once .NET 6 is released and we're able to update we can re-introduce paging limits.
@ajcvickers ajcvickers modified the milestones: 6.0.0-preview5, 6.0.0 Nov 8, 2021
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. customer-reported type-bug
Projects
None yet
Development

No branches or pull requests

4 participants