Extend Rule RSPEC-1590

plsql
tsql

(Christian Rohr ) #1

The rule RSPEC-1590 considers only an WHERE clause, but instead of the WHERE clause, an JOIN could be also valid. For example:

Non-compliant:

DELETE FROM dbo.Products;

Compliant:

DELETE FROM dbo.Products
WHERE ProductId = 1;

or

DELETE p 
FROM Products as p
INNER JOIN DeletedProducts as dp
ON p.ProductId = dp.ProductId

For UPDATE queries it’s similar.

Thank you :slight_smile:

Cheers

Chris


(Alexandre Gigleux) #3

Hello Chris,

While reading your post, I thought that you wanted to say that today S1590 is raising an issue on DELETE statements using INNER JOIN. So I tested it and so far so good, there is no issue raised by S1590 on such statements (at least your sample code).
Do you have on your side using the latest version of SonarTSQL (1.3.1 as of now) an issue raised on this statement?

DELETE p 
FROM Products as p
INNER JOIN DeletedProducts as dp
ON p.ProductId = dp.ProductId

Thanks
Alex