Skip to content

Commit ecca302

Browse files
committed
fix(types): exclude bool from vector fast-path; fix docstring and id() usage
- _types.py: bool is a subclass of int — add explicit not isinstance(v, bool) guard so [True, False] serialises as PropertyList, not Vector of 1.0/0.0 - __init__.py: docstring used result.rows but cypher() returns list[dict] directly - llama-index base.py: replace id(n)/id(m) (Neo4j internal IDs) with n.id/m.id (stored adapter property) in get_triplets() and get_rel_map() for consistent round-tripping with get(), upsert_relations(), and delete()
1 parent 3ee636e commit ecca302

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

coordinode/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
with CoordinodeClient("localhost:7080") as db:
99
result = db.cypher("MATCH (n:Concept) RETURN n LIMIT 5")
10-
for row in result.rows:
10+
for row in result:
1111
print(row)
1212
1313
Async::

coordinode/_types.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def to_property_value(py_val: PyValue) -> Any:
3737
# Homogeneous float list → Vector; mixed/str list → PropertyList
3838
# isinstance() with X|Y union syntax is valid from Python 3.10+ (PEP 604).
3939
# This package requires Python >=3.11, so no tuple-of-types workaround needed.
40-
if py_val and all(isinstance(v, int | float) for v in py_val):
40+
# bool is a subclass of int, so exclude it explicitly — [True, False] must
41+
# not be serialised as a Vector of 1.0/0.0 but as a PropertyList.
42+
if py_val and all(isinstance(v, (int, float)) and not isinstance(v, bool) for v in py_val):
4143
vec = Vector(values=[float(v) for v in py_val])
4244
pv.vector_value.CopyFrom(vec)
4345
else:

llama-index-coordinode/llama_index/graph_stores/coordinode/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def get_triplets(
131131
where = f"WHERE {' AND '.join(conditions)}" if conditions else ""
132132
cypher = (
133133
f"MATCH (n)-{rel_pattern}->(m) {where} "
134-
"RETURN n, type(r) AS rel_type, m, id(n) AS _src_id, id(m) AS _dst_id "
134+
"RETURN n, type(r) AS rel_type, m, n.id AS _src_id, m.id AS _dst_id "
135135
"LIMIT 1000"
136136
)
137137
result = self._client.cypher(cypher, params=params)
@@ -174,8 +174,8 @@ def get_rel_map(
174174

175175
cypher = (
176176
f"MATCH (n)-[r*1..{depth}]->(m) "
177-
f"WHERE id(n) IN $ids{ignore_clause} "
178-
f"RETURN n, r, m, id(n) AS _src_id, id(m) AS _dst_id "
177+
f"WHERE n.id IN $ids{ignore_clause} "
178+
f"RETURN n, r, m, n.id AS _src_id, m.id AS _dst_id "
179179
f"LIMIT {limit}"
180180
)
181181
result = self._client.cypher(cypher, params=params)

0 commit comments

Comments
 (0)