DapperLib / DapperLib/Dapper

Some strings can be cast as decimals and cause an overflow error

Open
#1,769 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I have an open SO thread on this, but after whittling it down to just a small amount of work (a basic select statement), I am more and more certain this is a bug with Dapper than something I have done wrong. (https://stackoverflow.com/questions/71698644/dapper-orm-some-db-values-returned-are-assessed-as-decimals-when-they-are-stri)

(I am using a SQL DB)
I have a table, which has a column [To], which is of type NVARCHAR(42).
If I SELECT this column, it usually works fine and my DTO, has the To property defined as a string.

There is one row which is causing issues however. When I try and SELECT it, I get the error Error parsing column 4(Value=0x942931035c59664564951677019130446debc886 - String). An inner exception shows as "Conversion overflows.", which appears to be coming from some get_Decimal() method.

The value in that column on the problematic row is 0x942931035c59664564951677019130446debc886.

To replicate, create a table with an NVARCHAR(42) column, and insert the above value. Then try and SELECT it, and convert to a DTO where the matching column is a string.

image

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 with the minimal reproduction described: create a SQL table with an NVARCHAR(42) column, insert the supplied hexadecimal value, and map a basic SELECT result to a DTO with a string property. Trace the column conversion that produces the decimal overflow, then verify that the value maps successfully without an overflow error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.