DapperLib / DapperLib/DapperAOT
SqlServer SQL Analyser false positives in update from into statement
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 472
- Forks
- 43
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 18
Description
Describe the bug
False positives of the T-Sql Analyser in a update ... output into ... from statement, see below.
Where are you seeing this?
- what Dapper/Dapper.StrongName version?
<PackageReference Include="Dapper" Version="2.1.35" />
- what Dapper.AOT/Dapper.Advisor version?
<PackageReference Include="Dapper.AOT" Version="1.0.31" />
- if relevant: what database backend?
- Microsoft Sql Server,
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.2.2" />
- Microsoft Sql Server,
To Reproduce
SqlConnection connection = .....
await connection.ExecuteAsync(@"
declare @t1 table(id int, val int)
declare @t2 table(id int, val int)
declare @t3 table(resultid int)
insert into @t1(id,val) values(1,1)
insert into @t2(id,val) values(1,20)
update t set
val = 2
output inserted.id into @t3(resultid)
from @t1 t
join @t2 t2 on t.id = t2.id
where t2.val > 10
");
Expected behavior
I expected no warnings, but got three, which at least in my opinion could all be considered false positives:
update t setproduced warning DAP225FROM expressions with multiple elements should use aliases
I didn't get this one in my production code, only in this minimal example, but I did update a regular table not a table variable, maybe that is the difference.
val = 2produced warning DAP226FROM expressions with multiple elements should qualify all columns; it is unclear where 'val' is located
This warning could possibly be considered valid, but I don't think it makes sense, because the update t set already specifies, that only columns of t can be updated...
into @t3(resultid)produced warning DAP226FROM expressions with multiple elements should qualify all columns; it is unclear where 'resultid' is located
This does not make sense, as resultid is not a column of any of the tables in the from clause.
Screenshots
Additional context
I just wanted to mention that I really like the analysers made available by Dapper.AOT, only very few false positives when I switched to AOT and great to find errors in SQL Queries!
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 with the Dapper.AOT T-SQL analyser and reproduce the update ... output into ... from example using the package versions listed. Check why DAP225 and DAP226 are emitted for the update target, assigned value, and output table; done means the valid statement produces no false-positive warnings while other qualification warnings remain covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100