feat: schema version tracking, SHA256 integrity, setup scripts, bug fixes
This commit is contained in:
@@ -2796,14 +2796,37 @@ impl PostgresDb {
|
||||
uuid: &str,
|
||||
) -> Result<Option<Chunk>> {
|
||||
let table = schema::table_name("chunk");
|
||||
let columns = "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";
|
||||
|
||||
// Try exact chunk_id match first
|
||||
let row = sqlx::query(&format!(
|
||||
"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
|
||||
"SELECT {} FROM {} WHERE chunk_id = $1 AND file_uuid = $2",
|
||||
columns, table
|
||||
))
|
||||
.bind(chunk_id)
|
||||
.bind(uuid)
|
||||
.fetch_optional(&self.pool)
|
||||
.await?;
|
||||
.bind(chunk_id)
|
||||
.bind(uuid)
|
||||
.fetch_optional(&self.pool)
|
||||
.await?;
|
||||
|
||||
// Fallback: if chunk_id is numeric (stale Qdrant payload), try matching by id
|
||||
let row = if row.is_some() {
|
||||
row
|
||||
} else if chunk_id.bytes().all(|b| b.is_ascii_digit()) {
|
||||
if let Ok(id) = chunk_id.parse::<i32>() {
|
||||
sqlx::query(&format!(
|
||||
"SELECT {} FROM {} WHERE id = $1 AND file_uuid = $2",
|
||||
columns, table
|
||||
))
|
||||
.bind(id)
|
||||
.bind(uuid)
|
||||
.fetch_optional(&self.pool)
|
||||
.await?
|
||||
} else {
|
||||
row
|
||||
}
|
||||
} else {
|
||||
row
|
||||
};
|
||||
|
||||
if let Some(r) = row {
|
||||
let chunk_type_str: String = r.get(3);
|
||||
|
||||
Reference in New Issue
Block a user