Extend Rule RSPEC-1590

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

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

Hi Alex

Sorry for my late response on this. You’re right in fact the rule works like it should be, so everything is fine.

Thank you very much.

Chris