zompinc / efcore-extensions

Provides window (analytics) functions and binary functions for EF Core. Providers: SQL Server, SQLite, Postgres.
MIT License
60 stars 6 forks source link

Exception during Npgsql ILike usage #12

Closed john-bartu closed 5 months ago

john-bartu commented 1 year ago

After adding dbBuilder.UseWindowFunctions();

Using Npgsql.ILike function raise System.InvalidOperationException: Unhandled expression exception

Reproduce:

var test = _context.AppEvents
            .Where(e => EF.Functions.ILike(e.Comment, "test"))
            .ToList();

Stack trace:

System.InvalidOperationException: Unhandled expression '[Microsoft.EntityFrameworkCore.Query.SqlExpressions.SelectExpression+ConcreteColumnExpression] ILIKE [Microsoft.EntityFrameworkCore.Query.SqlExpressions.SqlConstantExpression]' of type 'Npgsql.EntityFrameworkCore.PostgreSQL.Query.Expressions.Internal.PostgresILikeExpression' encountered in 'SqlNullabilityProcessor'.
   at Microsoft.EntityFrameworkCore.Query.SqlNullabilityProcessor.VisitCustomSqlExpression(SqlExpression sqlExpression, Boolean allowOptimizedExpansion, Boolean& nullable)
   at Zomp.EFCore.WindowFunctions.Query.Internal.WindowFunctionsSqlNullabilityProcessor.VisitCustomSqlExpression(SqlExpression sqlExpression, Boolean allowOptimizedExpansion, Boolean& nullable)
   at Microsoft.EntityFrameworkCore.Query.SqlNullabilityProcessor.Visit(SqlExpression sqlExpression, Boolean allowOptimizedExpansion, Boolean preserveColumnNullabilityInformation, Boolean& nullable)
   at Microsoft.EntityFrameworkCore.Query.SqlNullabilityProcessor.Visit(SqlExpression sqlExpression, Boolean allowOptimizedExpansion, Boolean& nullable)
   at Microsoft.EntityFrameworkCore.Query.SqlNullabilityProcessor.Visit(SelectExpression selectExpression)
   at Microsoft.EntityFrameworkCore.Query.SqlNullabilityProcessor.Process(Expression queryExpression, IReadOnlyDictionary`2 parameterValues, Boolean& canCache)
   at Zomp.EFCore.WindowFunctions.Query.Internal.WindowRelationalParameterBasedSqlProcessor.ProcessSqlNullability(Expression queryExpression, IReadOnlyDictionary`2 parametersValues, Boolean& canCache)
   at Microsoft.EntityFrameworkCore.Query.RelationalParameterBasedSqlProcessor.Optimize(Expression queryExpression, IReadOnlyDictionary`2 parametersValues, Boolean& canCache)
   at Microsoft.EntityFrameworkCore.Query.Internal.RelationalCommandCache.GetRelationalCommandTemplate(IReadOnlyDictionary`2 parameters)
   at Microsoft.EntityFrameworkCore.Internal.RelationCommandCacheExtensions.RentAndPopulateRelationalCommand(RelationalCommandCache relationalCommandCache, RelationalQueryContext queryContext)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.Enumerator.InitializeReader(Enumerator enumerator)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.Enumerator.<>c.<MoveNext>b__21_0(DbContext _, Enumerator enumerator)
   at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
   at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.Enumerator.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at CallManager.Backend.Services.Dashboard.EventService.GetAll(EventQueryFilter filter) in ~\CallManager.Backend\Services\Dashboard\EventService.cs:line 252
virzak commented 5 months ago

This has been fixed earlier in 1af6e2c