DapperLib / DapperLib/Dapper.Contrib

Found one bug in Dapper.Contrib (1.50.0.0) while inserting an entity with long id value

Open
#19 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
293
Forks
109
PR merge metrics
No merged PRs in 30d

Description

In class Dapper.Contrib.Extensions.SqlMapperExtensions we found one bug as below -

Starting from line number 47 -

int num;
    if (!flag)
    {
        num = **formatter.Insert(**connection, transaction, commandTimeout, tableName, stringBuilder.ToString(), stringBuilder2.ToString(), list, entityToInsert);
    }
    else
    {
        string text = string.Format("insert into {0} ({1}) values ({2})", tableName, stringBuilder, stringBuilder2);
        num = SqlMapper.Execute(connection, text, entityToInsert, transaction, commandTimeout, null);
    }
    if (expr_121)
    {
        connection.Close();
    }
    return (long)num;

formatter.Insert is returning long but getting stored in int variable. This is a bug and must be fixed soon.

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

In Dapper.Contrib.Extensions.SqlMapperExtensions, start around line 47 and inspect the formatter.Insert result and its local variable. Confirm the insertion path preserves a long ID value and check the surrounding insert behavior; done means entities with long IDs insert without truncation or overflow.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
databases
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.