Skip to content

Commit

Permalink
fix: Weaviate schema class name conversion which preserves PascalCase (
Browse files Browse the repository at this point in the history
…#707)

* fix: Weaviate schema class name conversion which preserves PascalCase

* adding a test case for schema name conversion

* linting

* formatting

---------

Co-authored-by: David S. Batista <[email protected]>
  • Loading branch information
chrisk314 and davidsbatista authored May 3, 2024
1 parent ca87b0e commit 5c7e1b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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"

0 comments on commit 5c7e1b7

Please sign in to comment.