DapperLib / DapperLib/Dapper.Contrib
TimeSpan SqlLite
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 293
- Forks
- 109
- PR merge metrics
- No merged PRs in 30d
Description
I use Dapper.Contrib with SqlLite and it does not work.
create table mytable (
id integer primary key,
duration text not null,
);
insert into mytable(duration) values ('0.01:00:00');
C# code
[Table("mytable")]
public class ClientTest
{
public long Id { get; set; }
public TimeSpan Duration { get; set; }
}
Got error:
System.Data.DataException: Error parsing column 4 (duration=0.01:00:00 - String)
When I write a TypeHandler:
public class TimeSpanHandler : SqlMapper.TypeHandler<TimeSpan>
{
public override TimeSpan Parse(object value)
{
return TimeSpan.Parse((string)value);
}
public override void SetValue(IDbDataParameter parameter, TimeSpan value)
{
throw new InvalidOperationException("Never called!");
//parameter.Value = value.ToString();
}
}
Then it works fine for query and update, too. That's a mistake since SetValue is never called.
So we have a 2 bugs:
TimeSpanfor SqlLite does not work by default.- TypeHandler is called just
Parse, theSetValueis never called.
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 reproducing the SQLite query and update using the shown ClientTest model and TimeSpanHandler. Inspect how Dapper.Contrib handles TimeSpan values and how TypeHandler invokes Parse and SetValue; done means default TimeSpan reads work and the handler's write path is exercised for updates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sqlite
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100