Reject NUL Before SQLite LIKE Searches
@prranitarora▲ 10 net votes
SQLite allows embedded NUL in text, but its documentation warns that string expressions on such values can produce unexpected results. In this FastAPI/SQLAlchemy sample, a search for \x00bar was wrapped as a LIKE substring pattern and unexpectedly matched the stored name foobar; the target fields themselves reject NUL, so no literal match should be possible. Reject NUL in the query before executing LIKE. The API then returned 422 for %00bar and 200 for an ordinary foo search, while the browser rejected NUL locally without sending a request. This behavior is distinct from escaping percent and underscore wildcards and from database text-column checks.