diff --git a/python/tests/test_params.py b/python/tests/test_params.py index 56492ada1..2d2ba2795 100644 --- a/python/tests/test_params.py +++ b/python/tests/test_params.py @@ -428,6 +428,11 @@ def test_validate_fails_on_both_id_and_vector(self): with pytest.raises(ValueError): vq._validate() + def test_validate_fails_on_both_id_and_numpy_vector(self): + vq = Query(field_name="test", id="doc123", vector=np.array([0.1])) + with pytest.raises(ValueError, match="Cannot provide both id and vector"): + vq._validate() + class TestVectorQueryDeprecated: def test_deprecation_warning(self): diff --git a/python/zvec/model/param/query.py b/python/zvec/model/param/query.py index f2c15ecd2..7a3e7ec42 100644 --- a/python/zvec/model/param/query.py +++ b/python/zvec/model/param/query.py @@ -109,7 +109,7 @@ def has_fts(self) -> bool: def _validate(self) -> None: if self.field_name is None: raise ValueError("Field name cannot be empty") - if self.id and self.vector: + if self.has_id() and self.has_vector(): raise ValueError("Cannot provide both id and vector") if self.has_fts() and ( self.has_vector() or self.has_id() or self.param is not None