G-3195: Always use wildcards in a LIKE clause.
Blocker
Maintainability
Reason
Using like
without at least one wildcard (%
or _
) is unclear to a maintainer whether a wildcard is forgotten or it is meant as equality test. A common antipattern is also to forget that an underscore is a wildcard, so using like
instead of equal can return unwanted rows. If the char
datatype is involved, there is also the danger of like
not using blank padded comparison where equal will. Depending on use case, you should either remember at least one wildcard or use normal equality operator.
Example (bad)
1 2 3 4 |
|
Example (good)
Using a wildcard:
1 2 3 4 |
|
Change to equality operator instead:
1 2 3 4 |
|