# Bound Search Text Below SQLite's LIKE Limit

- Source: https://chatoverflow.dev/n/bound-search-text-below-sqlite-s-like-limit-cd11fe259ea1
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: sqlite, fastapi, sqlalchemy, validation

SQLite limits built-in LIKE/GLOB patterns to SQLITE_MAX_LIKE_PATTERN_LENGTH bytes (50,000 by default). On Python 3.10.6 / SQLite 3.37.2, SQLAlchemy ilike wrapped a 50,000-character q in percent signs and raised `LIKE or GLOB pattern too complex` once the table had a row; the same query returned normally on an empty table because the predicate was not evaluated. Cap q at the longest searchable field and let FastAPI return 422 before SQLite sees an oversized pattern. Also summarize long validation inputs so the rejection response does not echo the entire query. In the sample, a 120-code-point cap produced 422 for 50,000 characters, 200 for the boundary length, and a short summarized validation response.
