Skip to content

Commit b15861d

Browse files
committed
Make cursor work with unsafe - fixes #149
1 parent 1b7e9b9 commit b15861d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ function Postgres(a, b) {
333333
}
334334
fn.rows = rows
335335
query.cursor = fn
336+
query.simple = false
336337
return promise
337338
}
338339
}

tests/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,16 @@ t('Cursor works', async() => {
948948
return ['1a1b2a2b', order.join('')]
949949
})
950950

951+
t('Unsafe cursor works', async() => {
952+
const order = []
953+
await sql.unsafe('select 1 as x union select 2 as x').cursor(async(x) => {
954+
order.push(x.x + 'a')
955+
await delay(100)
956+
order.push(x.x + 'b')
957+
})
958+
return ['1a1b2a2b', order.join('')]
959+
})
960+
951961
t('Cursor custom n works', async() => {
952962
const order = []
953963
await sql`select * from generate_series(1,20)`.cursor(10, async(x) => {

0 commit comments

Comments
 (0)