DbString Length can silently truncate value
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
If the DbString Length is set smaller than the value of the actual string, whether or not the IsAnsi flag is true or false, the value passed into the DbString will be silently truncated in the database call.
We experienced this in one of our apps when the value we passed in was greater than the length value specified in the dapper code and the resulting search came back with different data. Our fix was to build our own nuget package that would set the DbString length to the size of the string value.
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 in Dapper/DynamicParameters.cs at line 276 and inspect how DbString.Length and IsAnsi are applied when parameter values are longer than the configured length. Reproduce the described database-call behavior with an oversized string, then verify that the chosen handling no longer silently truncates the value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100