Dapper looses parameters
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
In some rare cases Dapper sends requests to SQLServer without parameters. I was able to reproduce it in test project:
https://github.com/dj-raphael/Dapper-test-lost-parameters
To reproduce, you should start this project in Visual Studio in Debug mode and wait for about a minute. However we encounter this problem from time to time (very rarely) in Release build on our production server. Here is the screenshot of exception we get:
https://github.com/dj-raphael/Dapper-test-lost-parameters/blob/master/exception.png
Here is the log obtained using MiniProfiler.Integrations library, I'm logging sql request before it was sent to SQLServer
try
{
...
var result = await connection.QueryAsync(sql.ToString(), map: Map, types: types, splitOn: splitOn, param: parameterValues).ConfigureAwait(false);
}
catch (SqlException e)
{
e.Data["profile-query-after-dapper"] = profiler.GetCommands();
e.AppendExceptionData(sql.ToString(), parameterValues);
throw;
}
https://github.com/dj-raphael/Dapper-test-lost-parameters/blob/master/example-log.txt
Log shows that I'm passing parameters to Dapper but SQLServer receives a request without any parameters at all. Another interesting fact is that it happens only when at least one of parameters is an array.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the linked Dapper-test-lost-parameters reproduction in Visual Studio Debug mode and inspect the QueryAsync call shown in the issue, especially when an array parameter is present. Compare the parameters passed to Dapper with the SQL Server request and use the linked exception and example-log files to establish a reliable reproduction and identify when parameters are lost.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100