Open karuakun opened 7 months ago
Ah, the effects of this disruptive change. https://learn.microsoft.com/en-us/ef/core/what-is-new/ef-core-8.0/whatsnew#better-use-of-in-queries
But I think I need another workaround, since MySQL does not allow the use of LIMIT clauses in subqueries of IN clauses
@lauxjpn if there's a MySQL limitation around LIMIT within IN subqueries, it should be possible to write a post-processing visitor to convert such subqueries to EXISTS ones... The EF query pipeline may have some issues making this more difficult than it should be - let me know if you need any assistance.
This issue also effects the openiddict package when using the PruneAsync function. ( The Pomelo provider is recommended by the author) https://github.com/openiddict/openiddict-core
@lauxjpn if there's a MySQL limitation around LIMIT within IN subqueries, it should be possible to write a post-processing visitor to convert such subqueries to EXISTS ones... The EF query pipeline may have some issues making this more difficult than it should be - let me know if you need any assistance.
@roji So you can give me a code example to solve this problem, thank you very much.
Is there a solution to this problem? It is impossible to execute the method 'PruneAsync' in OpenIddict
This issue also effects the openiddict package when using the PruneAsync function. ( The Pomelo provider is recommended by the author) https://github.com/openiddict/openiddict-core
Is there a solution to this problem? It is impossible to execute the method 'PruneAsync' in OpenIddict
@RichardArling @namespacedevbox in OpenIdDict you can overcome this error using option DisableBulkOperations
.
builder.Services.AddOpenIddict()
.AddCore(options =>
{
options.UseEntityFrameworkCore()
.DisableBulkOperations()
.UseDbContext<OpendIdDictContext>();
});
This issue also effects the openiddict package when using the PruneAsync function. ( The Pomelo provider is recommended by the author) https://github.com/openiddict/openiddict-core
Is there a solution to this problem? It is impossible to execute the method 'PruneAsync' in OpenIddict
@RichardArling @namespacedevbox in OpenIdDict you can overcome this error using option
DisableBulkOperations
.builder.Services.AddOpenIddict() .AddCore(options => { options.UseEntityFrameworkCore() .DisableBulkOperations() .UseDbContext<OpendIdDictContext>(); });
Thank you, you saved my life!
any update on this one ? is a fix planned ? Thanks in advance
If you don't want to disable bulk operations, you can use something like this
// There is currently an error in Pomelo.EntityFrameworkCore.MySql when use PruneAsync
//await _tokenManager.PruneAsync(DateTimeOffset.UtcNow);
var count = 0;
do
{
var tokens = await _dbContext.Set<OpenIddictEntityFrameworkCoreToken>()
.Include(x => x.Authorization)
.Where(x => x.Status != Statuses.Valid ||
(x.Authorization != null && x.Authorization.Status != Statuses.Valid) ||
x.ExpirationDate < DateTime.UtcNow)
.OrderBy(x => x.ExpirationDate)
.Take(1000)
.ToListAsync();
count = tokens.Count;
if (count > 0)
{
_dbContext.Set<OpenIddictEntityFrameworkCoreToken>().RemoveRange(tokens);
await _dbContext.SaveChangesAsync();
}
} while (count > 0);
Steps to reproduce
After updating Pomelo.EntityFrameworkCore.MySql from 7.0.0 to 8.0.2, the following code now exits abnormally The reason is that the SQL that used to use the EXISTS clause has been translated as an IN clause, and now uses the LIMIT clause in the IN clause. Is there an option to revert to the previous (7.0.0) behavior?
The issue
Pomelo.EntityFrameworkCore.MySql 8.0.2
Pomelo.EntityFrameworkCore.MySql 7.0.0
Further technical details
MySQL version: 8.0 Operating system: docker / windows 11 10.0.22631 Pomelo.EntityFrameworkCore.MySql version: 7.0.0 / 8.0.2 Microsoft.AspNetCore.App version:
Other details about my project setup: