like-wildcard-escaping-ids
Installation
SKILL.md
LIKE wildcards in machine-generated ids
LIKE is not substring matching. _ matches any single character and % matches any run of them,
and neither is opt-in — they are live in every pattern unless you escape them. Machine-generated ids
are full of _: in one measured dataset, 1 748 of the ids contained one.
So a pattern built from the id abc_def also matches abcXdef. In a sweep that uses LIKE to decide
"is this id still referenced?", that means a row is spared because of an id it has nothing to do
with — the sweep deletes less than it should and reports success. In an inclusion query the same
mistake goes the other way and returns somebody else's row.
The pattern that works
Escape \, then _, then %, wrap the id in the delimiters it actually has in the column, and
declare the escape character: