Compare commits

..

1 commit
v0.7.0 ... main

Author SHA1 Message Date
db359d35b2 fix(search): qualify ambiguous column names with table alias in FTS JOIN
Both log_fts and log_entries have timestamp_iso, severity, source_id, and
matched_patterns columns. After the JOIN, unqualified references to any of
these caused SQLite to raise 'ambiguous column name', silently falling back
to the non-FTS scan path on every time-filtered or severity-filtered query.

Prefix all filter conditions that touch FTS-mirror columns with f. to
resolve the ambiguity. The e. prefix on tenant_id was already correct since
tenant_id is not present in the FTS virtual table.
2026-06-17 11:27:38 -07:00

View file

@ -244,19 +244,19 @@ def _sqlite_fts_search(
params: list = [fts_query, tid] params: list = [fts_query, tid]
if severity: if severity:
conditions.append("severity = ?") conditions.append("f.severity = ?")
params.append(severity.upper()) params.append(severity.upper())
if source_filter: if source_filter:
conditions.append("source_id LIKE ?") conditions.append("f.source_id LIKE ?")
params.append(f"%{source_filter}%") params.append(f"%{source_filter}%")
if pattern_filter: if pattern_filter:
conditions.append("matched_patterns LIKE ?") conditions.append("f.matched_patterns LIKE ?")
params.append(f'%"{pattern_filter}"%') params.append(f'%"{pattern_filter}"%')
if since: if since:
conditions.append("timestamp_iso >= ?") conditions.append("f.timestamp_iso >= ?")
params.append(since) params.append(since)
if until: if until:
conditions.append("timestamp_iso <= ?") conditions.append("f.timestamp_iso <= ?")
params.append(until) params.append(until)
if not include_repeats: if not include_repeats:
conditions.append("f.repeat_count = 1") conditions.append("f.repeat_count = 1")