walker: flag LIKE on a numeric column (ADR-0027 Amendment 1)
LIKE is a text-pattern match; against a numeric column (int, real, decimal, serial) it runs but is almost never intended. predicate_warnings now emits a WARNING for it, spanned at the target column. New Type::is_numeric; catalog key diagnostic.like_numeric; ADR-0027 gains "Amendment 1" and the adr/README index line is updated per the index-upkeep rule. bool and the text-/blob-backed types are deliberately not flagged — see the amendment for the rationale. 3 walker tests (int, decimal NOT LIKE, text-column clean). 1108 passing, clippy clean.
This commit is contained in:
@@ -101,6 +101,18 @@ impl Type {
|
||||
]
|
||||
}
|
||||
|
||||
/// True for the numeric types — `int`, `real`, `decimal`,
|
||||
/// `serial`. `bool` (stored 0/1) and the text- / blob-backed
|
||||
/// types are not numeric. Used to flag a `LIKE` text-pattern
|
||||
/// match against a numeric column (ADR-0027, Amendment 1).
|
||||
#[must_use]
|
||||
pub const fn is_numeric(self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::Int | Self::Real | Self::Decimal | Self::Serial
|
||||
)
|
||||
}
|
||||
|
||||
/// The user-facing type that an FK column should use to
|
||||
/// reference a primary key of *this* type. For most types
|
||||
/// the answer is the same type; for `serial` and `shortid`
|
||||
|
||||
Reference in New Issue
Block a user