[CONJS-198] Feature request: checkNumberRange: boolean Created: 2022-05-30  Updated: 2022-06-02  Resolved: 2022-06-02

Status: Closed
Project: MariaDB Connector/node.js
Component/s: other
Affects Version/s: None
Fix Version/s: 3.0.1

Type: New Feature Priority: Major
Reporter: Diego Dupin Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

see https://github.com/mariadb-corporation/mariadb-connector-nodejs/issues/201

BigInt as a safe default is good, but I often find it quite impractical, because mariadb returns BIGINT from various operations like COUNT or col + 1 (note CAST(aBigInt AS INT) still results in BIGINT).
At the moment we can either choose to use the default safe behavior, but then we have to check the range and cast these to number manually or we can use bigIntAsNumber: true for convinience, but risk an invalid behavior in edge cases.
I propose introducing a new option, which would provide conviniency, but would fail loudly in case of possible error:
checkNumberRange: boolean
When set to true, the driver throws and error if DECIMAL/BIGINT can't be converted safely to number.
The option is only effective when one of insertIdAsNumber/decimalAsNumber/bigIntAsNumber is true.
Defaults to false for BC reasons.


Generated at Thu Feb 08 03:23:28 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.