(element)
| 78 | db_manager = manager |
| 79 | |
| 80 | def _get_eid(element): |
| 81 | if element is None: return None |
| 82 | if isinstance(element, (int, str)): |
| 83 | return str(element) |
| 84 | |
| 85 | # If element is a dict (like Neo4j returned items or KuzuDB node/rel dicts) |
| 86 | if isinstance(element, dict): |
| 87 | # KuzuDB _src / _dst are directly {'offset': X, 'table': Y} |
| 88 | if 'offset' in element and 'table' in element: |
| 89 | return f"{element.get('table')}_{element.get('offset')}" |
| 90 | |
| 91 | for key in ['_id', 'id', 'element_id']: |
| 92 | if key in element: |
| 93 | val = element[key] |
| 94 | if val is not None: |
| 95 | # KuzuDB returns dict IDs like {'offset': 1, 'table': 0} inside nodes |
| 96 | if isinstance(val, dict): |
| 97 | return f"{val.get('table', 0)}_{val.get('offset', 0)}" |
| 98 | return str(val) |
| 99 | return str(id(element)) |
| 100 | |
| 101 | # Try various ways to get ID (Neo4j, FalkorDB, etc. objects) |
| 102 | for attr in ['element_id', 'id', '_id']: |
| 103 | if hasattr(element, attr): |
| 104 | val = getattr(element, attr) |
| 105 | if val is not None: |
| 106 | # KuzuDB objects if any |
| 107 | if isinstance(val, dict): |
| 108 | return f"{val.get('table', 0)}_{val.get('offset', 0)}" |
| 109 | return str(val) |
| 110 | return str(id(element)) |
| 111 | |
| 112 | |
| 113 | @app.get("/api/graph") |
no test coverage detected