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:
@@ -39,7 +39,8 @@ runs if submitted).
|
||||
- **WARNING** — the input is valid and *will* run, but is
|
||||
very likely not what a knowledgeable user wants: a
|
||||
type-mismatched comparison, or `= NULL` (both from
|
||||
ADR-0026 §7).
|
||||
ADR-0026 §7). Amendment 1 adds a third trigger — `LIKE`
|
||||
against a numeric column.
|
||||
|
||||
The split is *certainty of failure* versus *likely
|
||||
misleading*. The indicator shows the highest severity
|
||||
@@ -289,6 +290,44 @@ choices and deviations from the sketch above:
|
||||
`input_verdict` has a parse-outcome / schema-existence /
|
||||
expression-warning / existing-cases-sweep test set.
|
||||
|
||||
## Amendment 1 — `LIKE` on a numeric column (2026-05-19)
|
||||
|
||||
§1 defined the WARNING set as exactly a type-mismatched
|
||||
comparison and `= NULL`. A third trigger is added:
|
||||
|
||||
- **`LIKE` against a numeric column.** `LIKE` is a
|
||||
text-pattern match — `%` / `_` wildcards over characters.
|
||||
Applied to a column of a numeric type (`int`, `real`,
|
||||
`decimal`, `serial`) it still runs — the engine matches the
|
||||
pattern against the value's text form — but is almost never
|
||||
what the user wants; they most likely mean a comparison or
|
||||
`BETWEEN`. It is a WARNING, consistent with the advisory
|
||||
posture (§5): the command still submits. The negation is
|
||||
irrelevant — `NOT LIKE` on a numeric column is just as
|
||||
dubious.
|
||||
|
||||
Scope is deliberately narrow — only *numeric* target columns
|
||||
are flagged:
|
||||
|
||||
- `bool` is integer-backed (0/1) but excluded; the handoff
|
||||
item this implements named numeric columns specifically.
|
||||
- The text-backed types (`text`, `shortid`, `date`,
|
||||
`datetime`) are not flagged: `LIKE 'A%'` on text is its
|
||||
intended use, and a prefix match on an ISO `date` /
|
||||
`datetime` string is genuinely useful.
|
||||
- `blob` is left unflagged.
|
||||
|
||||
Widening to those types is a future model extension if a need
|
||||
appears.
|
||||
|
||||
This is exactly the kind of "we can tell, before it runs,
|
||||
that this is dubious" case §6 anticipated: the trigger plugs
|
||||
into the existing model rather than being a one-off check. It
|
||||
lives alongside the others in `walker::predicate_warnings`
|
||||
(the `Predicate::Like` arm, via `like_numeric_warning`); the
|
||||
target column operand's span drives the highlight; the
|
||||
message key is `diagnostic.like_numeric`.
|
||||
|
||||
## See also
|
||||
|
||||
- ADR-0003 — input modes; the input field and its mode
|
||||
|
||||
Reference in New Issue
Block a user