-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
System.NotImplementedException for Precompiled Query with detailed errors enabled #34393
Comments
Bit more info on this Its actually part of the shaper created in It is part of the function When you have detailed erros enabled you have the following block that executes of which it doesn't seem like the precompile undewrstands it yet
It is simple to recreate this issue - just add
|
Thanks @ChrisJollyAU, the new precompiled query support is quite a massive piece of work, and there are definitely quite a few holes in there. Will put this on the consider list for 10, as we make the NativeAOt support more mature and hopefully bring it out of experimental status. |
Might have a go at this sometime |
Sure thing! Feel free to submit a PR. |
Had a look at this. I think this may need a further discussion with design. Here's the thing, NotImplemented is entirely correct. From what I understand (and I haven't done much with syntax generation and precompiled), the Try..catch can only be a statement and not an expression so you should never hit In this case looking at the call stack it is preceded by a
Note that when detailed errors are enabled, calls to the I don't believe you can have a try...catch in the initializer of an array and it doesn't look like the Somethings to think about:
|
@ChrisJollyAU LINQ expression trees are indeed different from C# syntax: in LINQ expression trees, various things (e.g. try/catch) can be expressions although in C# they cannot. As a result, the translator needs to deal with these cases by lifting out the incompatible expression, doing something like the following: int temp;
try
{
temp = dataReader.GetInt32(0);
}
catch (...) { ...};
return new object[] { temp, ... } The translator already does this for various constructs - take a look at the various tests; the same would need to be done for try/catch. |
Ok, here's my attempt. PrecompiledQuerySqlServerTest and AdHocPrecompiledQuerySqlServerTest (and same with sqlite) are all working locally |
I am busy adding the PrecompiledQuery functionality to EFCore.Jet provider including its test suite and have run into an error I'm not sure about
When running a test (e.g.
BinaryExpression
) inPrecompiledQueryJetTest
(outside of naming and such pretty much similar toPrecompiledQuerySqlServerTest
), I end up with the following errorIt obviously doesn't happen with Sql Server or Sqlite.
Debugging info
This seems to have something to do with the Execution Strategy being used. When it uses the default
NonRetryingExecutionStrategy
it comes up with the above error. However if I use the retrying execution strategy (JetRetryingExecutionStrategy
orTestJetRetryingExecutionStrategy
) it works fine as expected.Further debugging brings me to the
CompileQuery
function within theProcessSyntaxTree
in this file https://github.com/dotnet/efcore/blob/main/src/EFCore.Design/Query/Internal/PrecompiledQueryCodeGenerator.cs#L188It is further in the
ProcessSyntaxTree
function when it callsGenerateQueryExecutor
that we get the error.Looking at the debug view of the
queryExecutor
variable we see the following difference (only relevant part shown - not the whole view)This is what I get with Sql Server and Sqlite
This is what I get on EFCore.Jet
Note the part where the data reader call is wrapped in a try...catch. Not sure why it is being generated
As a further note, in the
VisitTry
function ofLinqToCSharpSyntaxTranslator
, the_context
variable that theswitch
is done on isExpressionContext.Expression
hence theNotImplementedException
I know its still marked as experimental so maybe I have hit something not finished yet
SDK: .Net 9 preview 6
Visual Studio: 17.11.0 preview 7
EF Core: 9.0.0-rc.1.24374.2 ( a daily build a day or 2 after the last preview 7 so should be close to what the final preview 7 release will be)
Using the preview 6 branch of efcore to build and debug on the SQL Server and Sqlite for comparison
Any thoughts?
The text was updated successfully, but these errors were encountered: