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: Weaviate schema class name conversion which preserves PascalCase #707

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ def __init__(
}
else:
# Set the class if not set
collection_settings["class"] = collection_settings.get("class", "default").capitalize()
_class_name = collection_settings.get("class", "Default")
_class_name = _class_name[0].upper() + _class_name[1:]
collection_settings["class"] = _class_name
# Set the properties if they're not set
collection_settings["properties"] = collection_settings.get("properties", DOCUMENT_COLLECTION_PROPERTIES)

Expand Down
15 changes: 15 additions & 0 deletions integrations/weaviate/tests/test_document_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,3 +664,18 @@ def test_filter_documents_over_default_limit(self, document_store):
document_store.write_documents(docs)
with pytest.raises(DocumentStoreError):
document_store.filter_documents({"field": "content", "operator": "==", "value": "This is some content"})

def test_schema_class_name_conversion_preserves_pascal_case(self):
collection_settings = {"class": "CaseDocument"}
doc_score = WeaviateDocumentStore(
url="http://localhost:8080",
collection_settings=collection_settings,
)
assert doc_score._collection_settings["class"] == "CaseDocument"

collection_settings = {"class": "lower_case_name"}
doc_score = WeaviateDocumentStore(
url="http://localhost:8080",
collection_settings=collection_settings,
)
assert doc_score._collection_settings["class"] == "Lower_case_name"