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).
Context
Since JSqlParser 5.4 (#1077), a bare unqualified column named
year,monthordayparses as aDateUnitExpressioninstead of aColumn.t.yearis still aColumn, and 5.3 parsed both asColumn.Enforcement is unaffected: masking, the table allow-list and row security don't rely on those column nodes. The rewritten SQL now reads
YEARforyear, which is the same column, since unquoted identifiers are case-insensitive.Two SQL review heuristics do lose coverage:
Tautologies(where_always_true):left instanceof Columnno longer matches, soWHERE year = yearis not reported.CrossJoinRule:instanceof Columnpairs skip a bareyear = …join condition, so correlation detection can misfire. This only matters for unqualified names, so the practical impact is small.Proposal
Treat a
DateUnitExpressionin an operand position as a bare column reference in the sqlreview helpers, for example with a smallColumnLikeadapter insqlreview/internal/rules/. Only if this proves noisy, consider pinning the old behaviour with a parser feature flag instead.Acceptance criteria
WHERE year = yearandWHERE month = monthare reported bywhere_always_true.CrossJoinRuletreats aDateUnitExpressionoperand the same way it treats an unqualifiedColumn.TautologiesTest/CrossJoinRuleTest(or the rule tests) coveryear,monthandday.Depends on #1077 (JSqlParser 5.4).