Should DbDataReader implementations be supported that return System.Nullable<X> from GetFieldType?
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
https://github.com/yellowfeather/DbfDataReader currently returns DateTime? from GetFieldType. When Dapper matches this against a DateTime? constructor parameter, it first unwraps the constructor parameter type to DateTime and then requires it to match the DateTime? it got from GetFieldType.
Because typeof(DateTime) == typeof(DateTime?) fails, Dapper then proceeds to show a very confusing error message saying that did not find a constructor with a signature that matches DateTime? x, even though it did. Wouldn't it make sense to detect that the problem is not with the constructor, whether or not this is considered a bug in DbfDataReader?
I would expect Dapper to either tolerate this or provide an error message explaining that the data reader implementation is buggy, rather than saying that a constructor signature doesn't exist which does exist. Which way sounds best to you?
These are the lines that would need to be changed:
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/DefaultTypeMap.cs at lines 81-82 and trace how DbDataReader.GetFieldType() is matched against nullable constructor parameters. Decide whether the mapping should tolerate System.Nullable or report the data-reader mismatch, then add coverage that verifies the resulting behavior and message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100