DapperLib / DapperLib/Dapper

Wrong GridIndex for Identity

Open
#1,766 1 comment 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

I had a problem with QueryAsync (error sql parameter not found, but I use a dynamicparameter) and found out that the "Identity" default constructor use GridIndex with 0, but it should use -1 (for dynamic Parameters). Before calling QueryAsync I used QueryMultiple with the same sql statement and GridReader.ReadAsync cached the query with no parameters. So there was an error in QueryAsync that no parameters were passed to the SqlCommand.

Wrong:
internal Identity(string sql, CommandType? commandType, IDbConnection connection, Type type, Type parametersType)
: this(sql, commandType, connection.ConnectionString, type, parametersType, 0, 0) { /* base call */ }

Correct:
internal Identity(string sql, CommandType? commandType, IDbConnection connection, Type type, Type parametersType)
: this(sql, commandType, connection.ConnectionString, type, parametersType, 0, -1) { /* base call */ }

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 at the Identity constructor shown in the issue and trace how QueryMultiple, GridReader.ReadAsync, and QueryAsync use its GridIndex. Reproduce the parameterized-query sequence, then verify that QueryAsync supplies its SQL parameters after a prior QueryMultiple call with the same SQL.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.