Skip to content

sqlreview: restore coverage of bare year/month/day columns after JSqlParser 5.4 #1080

Description

@babltiga

Context

Since JSqlParser 5.4 (#1077), a bare unqualified column named year, month or day parses as a DateUnitExpression instead of a Column. t.year is still a Column, and 5.3 parsed both as Column.

Enforcement is unaffected: masking, the table allow-list and row security don't rely on those column nodes. The rewritten SQL now reads YEAR for year, which is the same column, since unquoted identifiers are case-insensitive.

Two SQL review heuristics do lose coverage:

  • Tautologies (where_always_true): left instanceof Column no longer matches, so WHERE year = year is not reported.
  • CrossJoinRule: instanceof Column pairs skip a bare year = … join condition, so correlation detection can misfire. This only matters for unqualified names, so the practical impact is small.

Proposal

Treat a DateUnitExpression in an operand position as a bare column reference in the sqlreview helpers, for example with a small ColumnLike adapter in sqlreview/internal/rules/. Only if this proves noisy, consider pinning the old behaviour with a parser feature flag instead.

Acceptance criteria

  • WHERE year = year and WHERE month = month are reported by where_always_true.
  • CrossJoinRule treats a DateUnitExpression operand the same way it treats an unqualified Column.
  • Regression tests in TautologiesTest / CrossJoinRuleTest (or the rule tests) cover year, month and day.

Depends on #1077 (JSqlParser 5.4).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendbugSomething isn't workingjavaPull requests that update java code

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions