fix: M4 Phase 1 bugs - dev.chunks refs, search_path, uuid column
Bug fixes from M4 report: - 4 remaining dev.chunks → dev.chunk in SQL queries - search_path includes public for pgvector extension - get_chunk_by_chunk_id_and_uuid: uuid → file_uuid - New endpoint: GET /api/v1/file/:uuid/chunk/:chunk_id
This commit is contained in:
@@ -741,8 +741,8 @@ impl PostgresDb {
|
||||
let schema = schema.to_string();
|
||||
tracing::debug!("after_connect: setting search_path to {}", schema);
|
||||
Box::pin(async move {
|
||||
// Always set search_path explicitly to avoid using default "dev, public"
|
||||
sqlx::query(&format!("SET search_path TO {}", schema))
|
||||
// Include public schema for pgvector extension
|
||||
sqlx::query(&format!("SET search_path TO {}, public", schema))
|
||||
.execute(conn)
|
||||
.await?;
|
||||
Ok(())
|
||||
@@ -2774,7 +2774,7 @@ impl PostgresDb {
|
||||
) -> Result<Option<Chunk>> {
|
||||
let table = "dev.chunk";
|
||||
let row = sqlx::query(&format!(
|
||||
"SELECT COALESCE(file_id, 0) as file_id, uuid, chunk_id, chunk_type, COALESCE(fps, 24.0) as fps, COALESCE(start_frame, 0) as start_frame, COALESCE(end_frame, 0) as end_frame, text_content, content, metadata, vector_id, COALESCE(frame_count, 0) as frame_count, pre_chunk_ids, parent_chunk_id, child_chunk_ids, visual_stats FROM {} WHERE chunk_id = $1 AND uuid = $2",
|
||||
"SELECT COALESCE(file_id, 0) as file_id, file_uuid, chunk_id, chunk_type, COALESCE(fps, 24.0) as fps, COALESCE(start_frame, 0) as start_frame, COALESCE(end_frame, 0) as end_frame, text_content, content, metadata, vector_id, COALESCE(frame_count, 0) as frame_count, pre_chunk_ids, parent_chunk_id, child_chunk_ids, visual_stats FROM {} WHERE chunk_id = $1 AND file_uuid = $2",
|
||||
table
|
||||
))
|
||||
.bind(chunk_id)
|
||||
@@ -2821,7 +2821,7 @@ impl PostgresDb {
|
||||
|
||||
Ok(Some(Chunk {
|
||||
file_id,
|
||||
uuid: r.get("uuid"),
|
||||
uuid: r.get("file_uuid"),
|
||||
chunk_id: r.get("chunk_id"),
|
||||
|
||||
chunk_type,
|
||||
@@ -4623,7 +4623,7 @@ impl PostgresDb {
|
||||
COALESCE(summary_text, text_content, '') as summary,
|
||||
metadata,
|
||||
(1 - (embedding <=> $1::vector)) as similarity
|
||||
FROM dev.chunks
|
||||
FROM dev.chunk
|
||||
WHERE file_uuid = $2 AND chunk_type = 'cut' AND embedding IS NOT NULL
|
||||
ORDER BY embedding <=> $1::vector
|
||||
LIMIT $3
|
||||
|
||||
Reference in New Issue
Block a user