Skip to content
Open
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
1 change: 1 addition & 0 deletions cf/src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose

query = results = errorResponse = null
result = new Result()
rows = 0
connectTimer.cancel()

if (initial) {
Expand Down
1 change: 1 addition & 0 deletions cjs/src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose

query = results = errorResponse = null
result = new Result()
rows = 0
connectTimer.cancel()

if (initial) {
Expand Down
1 change: 1 addition & 0 deletions deno/src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose

query = results = errorResponse = null
result = new Result()
rows = 0
connectTimer.cancel()

if (initial) {
Expand Down
1 change: 1 addition & 0 deletions src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ function Connection(options, queues = {}, { onopen = noop, onend = noop, onclose

query = results = errorResponse = null
result = new Result()
rows = 0
connectTimer.cancel()

if (initial) {
Expand Down
10 changes: 10 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ t('Result has command', async() =>
['SELECT', (await sql`select 1`).command]
)

t('Result is not sparse after a query errors mid row-stream', async() => {
const sql = postgres({ ...options, max: 1 })
// Streams two rows, then errors on the third (division by zero), so the
// ErrorResponse arrives after DataRow messages and CommandComplete never fires.
await sql`select n, 1 / (3 - n) as boom from generate_series(1, 5) n`.catch(() => {})
const result = await sql`select x from generate_series(1, 3) x`
await sql.end()
return ['3:1,2,3', result.length + ':' + result.map(r => r.x).join(',')]
})

t('Create table', async() =>
['CREATE TABLE', (await sql`create table test(int int)`).command, await sql`drop table test`]
)
Expand Down