-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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: precision lost with bigint in sqlite3 #5482
base: master
Are you sure you want to change the base?
Conversation
add supportBigNumbers, bigNumberStrings options like mysql to support sqlite can read bigint by string
@kibertoad can you make a review for me ? |
let response = await statement.all(bindings); | ||
if(this.connectionSettings.supportBigNumbers) { | ||
const bigNumberStrings = this.connectionSettings.bigNumberStrings | ||
const processBigintModeRow = (row) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be simplified with:
const processBigintModeRow = (row) => {
return mapValues(row, v => {
if (typeof v === 'bigint') {
const numV = Number(v);
if (numV === v) {
return numV;
} else if (bigNumberStrings) {
return v.toString()
}
}
return v
})
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, this function can be simplified. However, there may be a problem with 'numV === v' because 1n === 1 is false.
add supportBigNumbers, bigNumberStrings options like mysql to support sqlite can read bigint by string