fix: collab update violating primary key

This commit is contained in:
Bartosz Sypytkowski 2024-06-28 07:11:33 +02:00
parent c1f8c486fd
commit 2f37f621b2
3 changed files with 6 additions and 6 deletions

View File

@ -1,13 +1,13 @@
{
"db_name": "PostgreSQL",
"query": "UPDATE af_collab SET blob = $2, len = $3, partition_key = $4, encrypt = $5, owner_uid = $6 WHERE oid = $1",
"query": "UPDATE af_collab SET blob = $3, len = $4, encrypt = $5, owner_uid = $6 WHERE oid = $1 AND partition_key = $2;",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Text",
"Bytea",
"Int4",
"Bytea",
"Int4",
"Int4",
"Int8"
@ -15,5 +15,5 @@
},
"nullable": []
},
"hash": "743186a1098002a840613d70da4e4106d481234bbe868de352100a69aaa8c66d"
"hash": "d4ce35ee25927744b46eb4c4a4b6b710669f8059b77e107b60993c939112e3a0"
}

View File

@ -76,11 +76,11 @@ pub async fn insert_into_af_collab(
if existing_workspace_id == workspace_id {
sqlx::query!(
"UPDATE af_collab \
SET blob = $2, len = $3, partition_key = $4, encrypt = $5, owner_uid = $6 WHERE oid = $1",
SET blob = $3, len = $4, encrypt = $5, owner_uid = $6 WHERE oid = $1 AND partition_key = $2;",
params.object_id,
partition_key,
params.encoded_collab_v1,
params.encoded_collab_v1.len() as i32,
partition_key,
encrypt,
uid,
)

View File

@ -83,7 +83,7 @@ pub async fn upsert_collab_embeddings(
)
.bind(&r.fragment_id)
.bind(&r.object_id)
.bind(r.collab_type.clone() as i32)
.bind(crate::collab::partition_key_from_collab_type(&r.collab_type))
.bind(r.content_type as i32)
.bind(&r.content)
.bind(r.embedding.clone().map(Vector::from))