DapperLib / DapperLib/Dapper

Error parsing column {index} ({name}={formattedValue}) has wrong formattedValue

Open
#1,323 5 comments 0 reactions 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

image

The circled value is data from the wrong column. It should be displaying a DateTime (of 0000-00-00) rather than the price column which is left of the datetime column.

This is using the implementation of mysql-net/MySqlConnector (current version and some previous versions).

I believe I've traced the code down to this in SqlMapper.cs but I'm not sure how to follow it back any further:

private static readonly MethodInfo
            enumParse = typeof(Enum).GetMethod(nameof(Enum.Parse), new Type[] { typeof(Type), typeof(string), typeof(bool) }),
            getItem = typeof(IDataRecord).GetProperties(BindingFlags.Instance | BindingFlags.Public)
                .Where(p => p.GetIndexParameters().Length > 0 && p.GetIndexParameters()[0].ParameterType == typeof(int))
                .Select(p => p.GetGetMethod()).First();

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 in SqlMapper.cs at the IDataRecord indexer reflection setup shown in the report, then trace how column indexes and formatted values are obtained when MySqlConnector is used. Reproduce the parsing error with the reported DateTime and price column ordering, and verify that the displayed formattedValue comes from the same column as the error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, mysql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.