False positives in plsql:DeleteOrUpdateWithoutWhereCheck

  • What language is this for?
    plsql
  • Which rule?
    plsql:DeleteOrUpdateWithoutWhereCheck
  • Why do you believe it’s a false-positive/false-negative?
    Declarations for triggers trigger the rule
  • Are you using
    • SonarQube - which version?
      v10.7
  • How can we reproduce the problem? Give us a self-contained snippet of code (formatted text, no screenshots)
alter table my.table
    add constraint my_constraint foreign key (a_field) references my.other_table (a_field) 
ON DELETE RESTRICT;

This triggers the rule indicating a where clause should be added, which doesn’t make sense.

Hello @fassen,

Thank you for reporting this issue to us!

From my understanding, ON DELETE applies to the add constraint statement, so it looks like an FP. The rule does not seem to make a difference between the DELETE statement and ON DELETE.

To make sure we cover all the scenarios could tell me the following:

  • Does it apply only to foreign key constraints?
  • Can you add a similar constraint with ON DELETE in a CREATE TABLE statement?

Thank you,

Hello again,

I was able to reproduce the issue and pinpoint where the issue was coming from.

So I confirm this is a false positive.
I have opened a ticket (internal link).

We sometimes wrongly parse the ON DELETE clause as a DELETE statement.

Have a nice day!

Thank you Sebastien! Sorry about the slow response, its been a busy week :technologist: