Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SqlServer SQL Analyser false positives in update from into statement #136

Open
TSlivede opened this issue Nov 11, 2024 · 0 comments
Open

Comments

@TSlivede
Copy link

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" />

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:

  1. update t set produced warning DAP225 FROM 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.

  1. val = 2 produced warning DAP226 FROM 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...

  1. into @t3(resultid) produced warning DAP226 FROM 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
grafik

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant