Skip to content

Commit

Permalink
Fix lastInsertId overflow (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyuhang0 authored Jul 8, 2024
1 parent 4ff097f commit a4febd9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions integration-test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('basic', () => {
last_name: 'base'
}
],
rowsAffected: 0,
rowsAffected: null,
lastInsertId: null,
rowCount: 1
}
Expand Down Expand Up @@ -96,7 +96,7 @@ describe('basic', () => {
last_name: 'base'
}
],
rowsAffected: 0,
rowsAffected: null,
lastInsertId: null,
rowCount: 1
}
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface FullResult {
statement: string
rowCount: number | null
rowsAffected: number | null
lastInsertId: number | null
lastInsertId: string | null
}

// serverless backend results
Expand All @@ -30,7 +30,7 @@ interface QueryExecuteResponse {
types: Field[] | null
rows: string[][] | null
rowsAffected: number | null
lastInsertID: number | null
sLastInsertID: string | null
}

const defaultExecuteOptions: ExecuteOptions = {}
Expand Down Expand Up @@ -133,8 +133,8 @@ export class Connection {
const rows = resp ? parse(fields, resp?.rows ?? [], cast, arrayMode, decoders) : []

if (fullResult) {
const rowsAffected = resp?.rowsAffected ?? 0
const lastInsertId = resp?.lastInsertID ?? null
const rowsAffected = resp?.rowsAffected ?? null
const lastInsertId = resp?.sLastInsertID ?? null
const typeByName = (acc, { name, type }) => ({ ...acc, [name]: type })
const types = fields.reduce<Types>(typeByName, {})
return {
Expand Down

0 comments on commit a4febd9

Please sign in to comment.