diff --git a/integration/test_vectors.py b/integration/test_vectors.py index 35538ad30..6c83811e8 100644 --- a/integration/test_vectors.py +++ b/integration/test_vectors.py @@ -271,6 +271,12 @@ def test_batch_add(collection_factory: CollectionFactory) -> None: assert obj.vector["title"] is not None assert obj.vector["bringYourOwn"] == [0.5, 0.25, 0.75] + obj = collection.query.fetch_object_by_id(uuid1, include_vector="bringYourOwn") + assert obj.vector == {"bringYourOwn": [0.5, 0.25, 0.75]} + + obj = collection.query.fetch_object_by_id(uuid1, include_vector=("bringYourOwn",)) + assert obj.vector == {"bringYourOwn": [0.5, 0.25, 0.75]} + def test_named_vector_with_index_config(collection_factory: CollectionFactory) -> None: collection = collection_factory( diff --git a/weaviate/collections/classes/grpc.py b/weaviate/collections/classes/grpc.py index 5cba315f7..6352c319e 100644 --- a/weaviate/collections/classes/grpc.py +++ b/weaviate/collections/classes/grpc.py @@ -148,6 +148,12 @@ class _MetadataQuery: def from_public( cls, public: Optional[MetadataQuery], include_vector: INCLUDE_VECTOR ) -> "_MetadataQuery": + # The branches below test only for `bool` and `list`, so a bare `str` or a tuple of names + # would otherwise request no vector at all and the caller would get none back, with no error. + if isinstance(include_vector, str): + include_vector = [include_vector] + elif isinstance(include_vector, tuple): + include_vector = list(include_vector) return ( cls( vector=include_vector if isinstance(include_vector, bool) else False,