fix(vector_stores): handle vector=None in Milvus and Qdrant update methods (#4568)

Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Utkarsh
2026-03-27 21:50:54 +05:30
committed by GitHub
co-authored by utkarsh240799 Claude Opus 4.6
parent 68cf4e118d
commit e87240d4d9
4 changed files with 134 additions and 2 deletions
+38
View File
@@ -15,6 +15,7 @@ from qdrant_client.models import (
MatchValue,
PointIdsList,
PointStruct,
PointVectors,
Range,
VectorParams,
)
@@ -232,6 +233,43 @@ class TestQdrant(unittest.TestCase):
self.assertEqual(point.vector, updated_vector)
self.assertEqual(point.payload, updated_payload)
def test_update_with_none_vector_uses_set_payload(self):
"""Test that update with vector=None uses set_payload instead of upsert (fixes #3708)."""
vector_id = str(uuid.uuid4())
updated_payload = {"key": "updated_value"}
self.qdrant.update(vector_id=vector_id, vector=None, payload=updated_payload)
self.client_mock.upsert.assert_not_called()
self.client_mock.set_payload.assert_called_once_with(
collection_name="test_collection",
payload=updated_payload,
points=[vector_id],
)
def test_update_with_none_payload_uses_update_vectors(self):
"""Test that update with payload=None uses update_vectors instead of upsert."""
vector_id = str(uuid.uuid4())
updated_vector = [0.2, 0.3]
self.qdrant.update(vector_id=vector_id, vector=updated_vector, payload=None)
self.client_mock.upsert.assert_not_called()
self.client_mock.update_vectors.assert_called_once_with(
collection_name="test_collection",
points=[PointVectors(id=vector_id, vector=updated_vector)],
)
def test_update_with_both_none_is_noop(self):
"""Test that update with both vector=None and payload=None is a no-op."""
vector_id = str(uuid.uuid4())
self.qdrant.update(vector_id=vector_id, vector=None, payload=None)
self.client_mock.upsert.assert_not_called()
self.client_mock.set_payload.assert_not_called()
self.client_mock.update_vectors.assert_not_called()
def test_get(self):
vector_id = str(uuid.uuid4())
self.client_mock.retrieve.return_value = [{"id": vector_id, "payload": {"key": "value"}}]