fix(search): cast query embedding to ::vector in search paper (DQ-4)
`codex search paper` crashed on the live DB with "operator does not exist: vector <-> double precision[]". The pgvector `<->` operator needs its RHS typed as vector; peer call sites (mcp_server.py, wiki.py) cast but the CLI did not. Mocked unit tests never exercise real pgvector, so it went unseen. Add the cast to both `<->` occurrences and a regression guard asserting the SQL contains `::vector`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -84,10 +84,10 @@ def search_paper(
|
||||
rows = conn.execute(
|
||||
"""
|
||||
SELECT id, title, year,
|
||||
abstract_emb <-> %(emb)s AS distance
|
||||
abstract_emb <-> %(emb)s::vector AS distance
|
||||
FROM papers
|
||||
WHERE abstract_emb IS NOT NULL
|
||||
ORDER BY abstract_emb <-> %(emb)s
|
||||
ORDER BY abstract_emb <-> %(emb)s::vector
|
||||
LIMIT %(limit)s
|
||||
""",
|
||||
{"emb": emb, "limit": limit},
|
||||
|
||||
Reference in New Issue
Block a user