Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lastInsertId overflow #66

Merged
merged 7 commits into from
Jul 8, 2024
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 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
Loading