Skip to main content

upsert_entity_vec

Function upsert_entity_vec 

Source
pub fn upsert_entity_vec(
    conn: &Connection,
    entity_id: i64,
    namespace: &str,
    entity_type: &str,
    embedding: &[f32],
    name: &str,
) -> Result<(), AppError>
Expand description

Replaces the vector row for an entity in vec_entities.

vec0 virtual tables do not honour INSERT OR REPLACE when the primary key already exists — they raise a UNIQUE constraint error instead of silently replacing the row. The workaround is an explicit DELETE before INSERT so that the insert never conflicts. embedding must have length crate::constants::EMBEDDING_DIM.

§Errors

Returns Err(AppError::Database) on any rusqlite failure.