mirror of
https://github.com/hwchase17/langchain
synced 2024-11-08 07:10:35 +00:00
bugfix: ArangoDB Empty Schema Case (#9574)
- Introduces a conditional in `ArangoGraph.generate_schema()` to exclude empty ArangoDB Collections from the schema - Add empty collection test case Issue: N/A Dependencies: None
This commit is contained in:
parent
1ea2f9adf4
commit
dfb9ff1079
@ -66,6 +66,10 @@ class ArangoGraph:
|
||||
col_type: str = collection["type"]
|
||||
col_size: int = self.db.collection(col_name).count()
|
||||
|
||||
# Skip collection if empty
|
||||
if col_size == 0:
|
||||
continue
|
||||
|
||||
# Set number of ArangoDB documents/edges to retrieve
|
||||
limit_amount = ceil(sample_ratio * col_size) or 1
|
||||
|
||||
|
@ -55,6 +55,21 @@ def test_connect_arangodb() -> None:
|
||||
assert ["hello_world"] == sample_aql_result
|
||||
|
||||
|
||||
def test_empty_schema_on_no_data() -> None:
|
||||
"""Test that the schema is empty for an empty ArangoDB Database"""
|
||||
db = get_arangodb_client()
|
||||
db.delete_graph("GameOfThrones", drop_collections=True, ignore_missing=True)
|
||||
db.delete_collection("empty_collection", ignore_missing=True)
|
||||
db.create_collection("empty_collection")
|
||||
|
||||
graph = ArangoGraph(db)
|
||||
|
||||
assert graph.schema == {
|
||||
"Graph Schema": [],
|
||||
"Collection Schema": [],
|
||||
}
|
||||
|
||||
|
||||
def test_aql_generation() -> None:
|
||||
"""Test that AQL statement is correctly generated and executed."""
|
||||
db = get_arangodb_client()
|
||||
|
Loading…
Reference in New Issue
Block a user