Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions python/tests/test_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion python/zvec/model/param/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading