WeKnora/internal/application
coderdailyone 0ad08d41be fix(repository): make message keyword search work on SQLite and MySQL
SearchMessagesByKeyword filtered with `messages.content ILIKE ?`, which is
PostgreSQL-only syntax. On SQLite (the Lite build) and MySQL the query fails
with `near "ILIKE": syntax error`, so POST /api/v1/messages/search returned
HTTP 500 in both keyword and the default hybrid modes. The session-list
search (QueryPaged) was already made dialect-aware for the same reason; this
path was missed.

Pick the LIKE expression per dialect — ILIKE on Postgres, LOWER() LIKE
LOWER() elsewhere — and add an explicit `ESCAPE ?` bound to likeEscapeChar so
escapeLikeKeyword's backslash escapes are honored on SQLite, which has no
default LIKE escape character (a no-op on Postgres/MySQL, where `\` is
already the default).

Regression tests in message_search_test.go run against in-memory SQLite:
TestSearchMessagesByKeywordMatchesOnSQLite and
TestSearchMessagesByKeywordTreatsWildcardsLiterally both fail on the old code
with the ILIKE syntax error and pass with the fix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CRrBenkCCr4pacMNwR4NuG
2026-09-17 12:27:52 +08:00
..
access refactor(resource-access): unify scoped authorization and transfer recovery (#3097) 2026-09-08 15:36:33 +08:00
repository fix(repository): make message keyword search work on SQLite and MySQL 2026-09-17 12:27:52 +08:00
service fix(repository): make message keyword search work on SQLite and MySQL 2026-09-17 12:27:52 +08:00