Fix AsyncPostgresStore._cursor row type (#4623)

`AsyncPostgresStore._cursor` is expected to yield
`AsyncCursor[DictRow]`. In the `else` branch the `row_factory` was not
defined, meaning that it would yield `AsyncCursor[TupleRow]` (default).
This resulted in an error in
[langgraph/store/postgres/aio.py#L249](https://github.com/langchain-ai/langgraph/blob/main/libs/checkpoint-postgres/langgraph/store/postgres/aio.py#L249)
(`TypeError: tuple indices must be integers or slices, not str`).
This commit is contained in:
André Menezes
2025-05-12 13:34:56 +00:00
committed by GitHub
parent 5ab6f77982
commit 3d394740ce
@@ -558,6 +558,6 @@ class AsyncPostgresStore(AsyncBatchedBaseStore, BasePostgresStore[_ainternal.Con
else:
async with (
self.lock,
conn.cursor(binary=True) as cur,
conn.cursor(binary=True, row_factory=dict_row) as cur,
):
yield cur