Find COUNT subqueries used as existence checks
ProprietaryA scalar COUNT subquery compared to 0 or 1 tallies every matching row even though the outcome is decided by the first one. EXISTS or NOT EXISTS lets the engine stop as soon as a match is found. Comparisons against other values, such as > 5, express a genuine cardinality requirement and are not flagged.
org. openrewrite. sql. antipattern. FindCountAsExistenceCheckOptional
markSourceBoolean
Whether to mark each occurrence in source, and apply the fix where the rule remediates. Defaults to true; set to false to leave source untouched and report only to the data table, as an analysis-only pipeline requires.
mod run . --recipe= org. openrewrite. sql. antipattern. FindCountAsExistenceCheckInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.