SqlServer query with array parameters produce invalid SQL when parameters names would collide
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 3.7k
- Avg merge
- 5h 8m
- Merged PRs (30d)
- 1
Description
SQL:
SELECT 1
FROM (SELECT 1 AS Id) [VALUES]
WHERE [VALUES].Id IN @p1
OR [VALUES].Id IN @p11
Parameters:
new
{
p1 = new [] { 1, 2 },
p11 = new [] { 3, 4 }
};
Produces the following SQL:
exec sp_executesql N'SELECT 1
FROM (SELECT 1 AS Id) [VALUES]
WHERE [VALUES].Id IN ((@p111,@p112),@p12)
OR [VALUES].Id IN (@p111,@p112)
',N'@p11 int,@p12 int,@p111 int,@p112 int',@p11=1,@p12=2,@p111=3,@p112=4
Dapper: 1.50.4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported SQL Server query with array parameters named p1 and p11, then trace the parameter expansion that produces the invalid SQL. Done means the generated SQL keeps the two array parameters distinct and executes with the expected values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100