Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions async_postgres/pg_client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2485,7 +2485,7 @@ proc closeCursorImpl(

cursor.exhausted = true

proc closeCursor*(cursor: Cursor): Future[void] {.async.} =
proc close*(cursor: Cursor): Future[void] {.async.} =
## Close the cursor and return the connection to ready state.
## On timeout, the connection is marked csClosed (protocol out of sync).
if cursor.timeout > ZeroDuration:
Expand All @@ -2512,7 +2512,7 @@ template withCursor*(
try:
body
finally:
await cursorName.closeCursor()
await cursorName.close()

proc openCursor*(
conn: PgConnection,
Expand Down
10 changes: 5 additions & 5 deletions tests/test_e2e.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,7 @@ suite "E2E: Cursor/Streaming":

waitFor t()

test "mid-stream closeCursor returns conn to ready":
test "mid-stream close returns conn to ready":
proc t() {.async.} =
let conn = await connect(plainConfig())
discard await conn.exec("DROP TABLE IF EXISTS test_cursor_close")
Expand All @@ -2145,7 +2145,7 @@ suite "E2E: Cursor/Streaming":
let chunk1 = await cursor.fetchNext()
doAssert chunk1.len == 10

await cursor.closeCursor()
await cursor.close()
doAssert conn.state == csReady

# Connection is usable after closing cursor mid-stream
Expand Down Expand Up @@ -2498,16 +2498,16 @@ suite "E2E: Cursor/Streaming":

waitFor t()

test "closeCursor on already exhausted cursor":
test "close on already exhausted cursor":
proc t() {.async.} =
let conn = await connect(plainConfig())
let cursor = await conn.openCursor("SELECT 1 AS x", chunkSize = 10)
let chunk = await cursor.fetchNext()
doAssert chunk.len == 1
doAssert cursor.exhausted

# closeCursor on exhausted cursor should be safe no-op
await cursor.closeCursor()
# close on exhausted cursor should be safe no-op
await cursor.close()
doAssert conn.state == csReady

let res = await conn.query("SELECT 2 AS y")
Expand Down
Loading