fix: correct parameter passing in delete_entity_relation
Why this change is needed: The previous fix in commit7dc1f83eincorrectly "fixed" delete_entity_relation by converting the parameter dict to a list. However, PostgreSQLDB.execute() expects a dict[str, Any] parameter, not a list. The execute() method internally converts dict values to tuple (line 1487: tuple(data.values())), so passing a list bypasses the expected interface and causes parameter binding issues. What was wrong: ```python params = {"workspace": self.workspace, "entity_name": entity_name} await self.db.execute(delete_sql, list(params.values())) # WRONG ``` The correct approach (matching delete_entity method): ```python await self.db.execute( delete_sql, {"workspace": self.workspace, "entity_name": entity_name} ) ``` How it solves it: - Pass parameters as a dict directly to db.execute(), matching the method signature - Maintain consistency with delete_entity() which correctly passes a dict - Let db.execute() handle the dict-to-tuple conversion internally as designed Impact: - delete_entity_relation now correctly passes parameters to PostgreSQL - Method interface consistency with other delete operations - Proper parameter binding ensures reliable entity relation deletion Testing: - All 6 PostgreSQL migration tests pass - Verified parameter passing matches delete_entity pattern - Code review identified the issue before production use Related: - Fixes incorrect "fix" from commit7dc1f83e- Aligns with PostgreSQLDB.execute() interface (line 1477-1480)
This commit is contained in:
parent
a0dfb47d0d
commit
4c12301e81
1 changed files with 3 additions and 2 deletions
|
|
@ -2604,8 +2604,9 @@ class PGVectorStorage(BaseVectorStorage):
|
|||
delete_sql = f"""DELETE FROM {self.table_name}
|
||||
WHERE workspace=$1 AND (source_id=$2 OR target_id=$2)"""
|
||||
|
||||
params = {"workspace": self.workspace, "entity_name": entity_name}
|
||||
await self.db.execute(delete_sql, list(params.values()))
|
||||
await self.db.execute(
|
||||
delete_sql, {"workspace": self.workspace, "entity_name": entity_name}
|
||||
)
|
||||
logger.debug(
|
||||
f"[{self.workspace}] Successfully deleted relations for entity {entity_name}"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue