DapperLib / DapperLib/Dapper

Retrieving decimal value from db causing an issue.

Open
#405 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

deserialization needs-investigation
Dominant language
C#
Stars
18.4k
Forks
3.7k
Avg merge
5h 8m
Merged PRs (30d)
1

Description

This seems like an edge case. If the decimal value with precision more than 6 digits & the value is zero, it is unable to cast it.

Interestingly If the decimal value in the DB is anything other than zero, then it is working fine.

Note 1: With decimal value precision is <= 6 everything works fine.
Note 2: I had only one row in the table

Table Definition:

CREATE TABLE Table1
(
   Name varchar(20) NOT NULL,
   Rate decimal(7,7)
)

Table Data:

|Name|Rate|
|Mano|0|

When trying to fetch rows is failing.

var sql = "SELECT Name, Rate FROM Table1"
connection.Query<dynamic>(sql);

Exception

Error parsing column 2 (RATE=1 - Int16)
----> System.FormatException : Input string was not in a correct format.

In case of additional information please revert back!

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the shown Table1 definition, zero decimal(7,7) value, and Query(sql) call. Trace Dapper's result-column conversion from the failing RATE value and add a regression test for zero values with precision above six digits; done means the query returns successfully without the FormatException.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.