Skip to content

Commit

Permalink
fix bigint (#52)
Browse files Browse the repository at this point in the history
Co-authored-by: Xiang Zhang <[email protected]>
  • Loading branch information
shiyuhang0 and zhangyangyu authored Feb 19, 2024
1 parent 136cd69 commit 471d777
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions __tests__/format.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,11 @@ describe('format', () => {
const expected = "select 1 from user where state = '\\Za\\Z'"
expect(format(query, ['\x1aa\x1a'])).toEqual(expected)
})

test('formats bigint values', () => {
const query = 'select 1 from user where id=? and id2=?'
const expected = 'select 1 from user where id=1 and id2=9223372036854775807'
expect(format(query, [1n,9223372036854775807n])).toEqual(expected)
})
})
})
2 changes: 1 addition & 1 deletion src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function sanitize(value: Value): string {
return 'null'
}

if (typeof value === 'number') {
if (['number', 'bigint'].includes(typeof value)) {
return String(value)
}

Expand Down

0 comments on commit 471d777

Please sign in to comment.