Skip to content

rule: W015 join-function-on-column - warn on JOIN ... ON f(col) = ... #5

Description

@Pawansingh3889

W003 function-on-column already catches function wrapping in WHERE.
The same pattern in JOIN ... ON is equally index-hostile but currently
slips through. Split into its own rule for clarity.

Should fail

SELECT *
FROM orders o
JOIN customers c ON UPPER(o.email) = UPPER(c.email);

Should pass

SELECT *
FROM orders o
JOIN customers c ON o.email_lower = c.email_lower;

Implementation hints

  • Single-line rule.
  • Look at W003 and reuse its function list (YEAR|MONTH|UPPER|LOWER|...).
  • Regex: r"\bJOIN\b.*\bON\b.*\b(YEAR|MONTH|DAY|UPPER|LOWER|TRIM|CAST|CONVERT|SUBSTRING)\s*\("
  • Severity: warning.

Estimated LOC: ~25 code + ~15 test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions