Skip to content

Commit 216bde0

Browse files
authored
Set session before throwing an error. (#129)
1 parent 12a1da7 commit 216bde0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,17 @@ export class Connection {
208208
const saved = await postJSON<QueryExecuteResponse>(this.config, url, { query: sql, session: this.session })
209209

210210
const { result, session, error, timing } = saved
211+
if (session) {
212+
this.session = session
213+
}
214+
211215
if (error) {
212216
throw new DatabaseError(error.message, 400, error)
213217
}
214218

215219
const rowsAffected = result?.rowsAffected ? parseInt(result.rowsAffected, 10) : 0
216220
const insertId = result?.insertId ?? '0'
217221

218-
this.session = session
219-
220222
const fields = result?.fields ?? []
221223
// ensure each field has a type assigned,
222224
// the only case it would be omitted is in the case of

0 commit comments

Comments
 (0)