Skip to content

Commit

Permalink
opt
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyuhang0 committed Jul 8, 2024
1 parent 555983f commit 9184f12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
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: bigint | 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: bigint | 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
3 changes: 0 additions & 3 deletions src/serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ export async function postQuery<T>(config: Config, body, session = '', isolation

if (response.ok) {
const resp = await response.json()
if ( resp.sLastInsertID ){
resp.lastInsertId = BigInt(resp.sLastInsertID)
}
const session = response.headers.get('TiDB-Session')
resp.session = session ?? ''
return resp
Expand Down

0 comments on commit 9184f12

Please sign in to comment.