Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: auto capitalize target collection in by_ref_multi_target #1471

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions integration/test_collection_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,3 +825,9 @@ def test_filter_by_ref_and_multi_ref(collection_factory: CollectionFactory) -> N
).objects

assert objects[0].uuid == uuid23


def test_auto_capitalize_first_letter_by_ref_multi_target() -> None:
result = Filter.by_ref_multi_target(link_on="ref1", target_collection="test")
target_collection_stored = result._FilterByRef__target.target_collection
assert target_collection_stored == "Test"
4 changes: 3 additions & 1 deletion weaviate/collections/classes/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from weaviate.collections.classes.types import _WeaviateInput
from weaviate.types import UUID
from weaviate.proto.v1 import base_pb2
from weaviate.util import get_valid_uuid
from weaviate.util import get_valid_uuid, _capitalize_first_letter

from weaviate.exceptions import WeaviateInvalidInputError

Expand Down Expand Up @@ -489,6 +489,7 @@ def by_ref(self, link_on: str) -> "_FilterByRef":

def by_ref_multi_target(self, reference: str, target_collection: str) -> "_FilterByRef":
"""Filter on the given multi-target reference."""
target_collection = _capitalize_first_letter(target_collection)
self.__last_target.target = _MultiTargetRef(
link_on=reference, target_collection=target_collection
)
Expand Down Expand Up @@ -537,6 +538,7 @@ def by_ref(link_on: str) -> _FilterByRef:
@staticmethod
def by_ref_multi_target(link_on: str, target_collection: str) -> _FilterByRef:
"""Define a filter based on a reference to be used when querying and deleting from a collection."""
target_collection = _capitalize_first_letter(target_collection)
return _FilterByRef(_MultiTargetRef(link_on=link_on, target_collection=target_collection))

@staticmethod
Expand Down
Loading