A WHERE condition on the table of a LEFT JOIN removes the rows the join adds
What it finds
FROM a LEFT JOIN b ON ... WHERE b.status = 'x': the condition on b is false for the rows the outer join adds, where b's columns are NULL, so it removes them, and the query works as an inner join. A condition meant to filter b belongs in the ON clause; a query meant to filter the result had better say JOIN.
Only conditions that are conjuncts of WHERE and compare a column of the joined table with a constant count; IS NULL tests and conditions under OR are left alone.
From the rule's source, left_join_filtered_in_where.rs.
Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/sql:left-join-filtered-in-where" = "warning"To keep one finding, suppress it with a reason: tx0 suppress ID --reason "..." writes the comment for it.
tx0 explain tx0/sql:left-join-filtered-in-where shows the same in the terminal. Found a false positive? Report it.