Revise the AGE implementation on get_node_edges, to align with Neo4j behavior.
This commit is contained in:
@@ -141,13 +141,16 @@ class PostgreSQLDB:
|
|||||||
await connection.execute(sql)
|
await connection.execute(sql)
|
||||||
else:
|
else:
|
||||||
await connection.execute(sql, *data.values())
|
await connection.execute(sql, *data.values())
|
||||||
except asyncpg.exceptions.UniqueViolationError as e:
|
except (
|
||||||
|
asyncpg.exceptions.UniqueViolationError,
|
||||||
|
asyncpg.exceptions.DuplicateTableError,
|
||||||
|
) as e:
|
||||||
if upsert:
|
if upsert:
|
||||||
print("Key value duplicate, but upsert succeeded.")
|
print("Key value duplicate, but upsert succeeded.")
|
||||||
else:
|
else:
|
||||||
logger.error(f"Upsert error: {e}")
|
logger.error(f"Upsert error: {e}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"PostgreSQL database error: {e}")
|
logger.error(f"PostgreSQL database error: {e.__class__} - {e}")
|
||||||
print(sql)
|
print(sql)
|
||||||
print(data)
|
print(data)
|
||||||
raise
|
raise
|
||||||
@@ -885,7 +888,12 @@ class PGGraphStorage(BaseGraphStorage):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if source_label and target_label:
|
if source_label and target_label:
|
||||||
edges.append((source_label, target_label))
|
edges.append(
|
||||||
|
(
|
||||||
|
PGGraphStorage._decode_graph_label(source_label),
|
||||||
|
PGGraphStorage._decode_graph_label(target_label),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
return edges
|
return edges
|
||||||
|
|
||||||
|
@@ -61,7 +61,7 @@ db = PostgreSQLDB(
|
|||||||
"port": 15432,
|
"port": 15432,
|
||||||
"user": "rag",
|
"user": "rag",
|
||||||
"password": "rag",
|
"password": "rag",
|
||||||
"database": "rag",
|
"database": "r1",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -74,8 +74,12 @@ async def query_with_age():
|
|||||||
embedding_func=None,
|
embedding_func=None,
|
||||||
)
|
)
|
||||||
graph.db = db
|
graph.db = db
|
||||||
res = await graph.get_node('"CHRISTMAS-TIME"')
|
res = await graph.get_node('"A CHRISTMAS CAROL"')
|
||||||
print("Node is: ", res)
|
print("Node is: ", res)
|
||||||
|
res = await graph.get_edge('"A CHRISTMAS CAROL"', "PROJECT GUTENBERG")
|
||||||
|
print("Edge is: ", res)
|
||||||
|
res = await graph.get_node_edges('"SCROOGE"')
|
||||||
|
print("Node Edges are: ", res)
|
||||||
|
|
||||||
|
|
||||||
async def create_edge_with_age():
|
async def create_edge_with_age():
|
||||||
|
Reference in New Issue
Block a user