You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deno_mysql currently treats MySQL's bigint and decimal as the JavaScript's Number.
However, these types cannot be accurately represented by the Number.
The following code reproduces this problem:
mod.ts:
import{Client}from"https://deno.land/x/mysql@1.9.1/mod.ts";constclient=awaitnewClient().connect({hostname: "localhost",port: 3306,username: "test",db: "test",password: "test",});awaitclient.query(`DROP TABLE IF EXISTS test`);awaitclient.query(`CREATE TABLE test ( id int(11) NOT NULL AUTO_INCREMENT, bigint_column bigint NOT NULL, decimal_column decimal(65,30) NOT NULL, PRIMARY KEY (id)) ENGINE=MEMORY DEFAULT CHARSET=utf8mb4`);constbigint="9223372036854775807";constdecimal="0.012345678901234567890123456789";awaitclient.execute(` INSERT INTO test (bigint_column, decimal_column) VALUES (${bigint}, ${decimal})`);console.log(awaitclient.query(`SELECT * FROM test`));
$ deno run --allow-net ./mod.ts
INFO connecting localhost:3306
INFO connected to localhost
[
{ id: 1, bigint_column: 9223372036854776000, decimal_column: 0.012345678901234568 }
]
deno@v0.42.0
deno_mysql@v1.9.1
Possible solutions
Always treat bigint and decimal as String (probably the simplest solution).
Provide options that change the handling of these types (like node-mysql).
node-mysql provides supportBigNumbers and bigNumberStrings options.
These are just ideas, so any feedback would be appreciated 😄
Summary
deno_mysql currently treats MySQL's
bigint
anddecimal
as the JavaScript'sNumber
.However, these types cannot be accurately represented by the
Number
.The following code reproduces this problem:
mod.ts:
Possible solutions
bigint
anddecimal
asString
(probably the simplest solution).supportBigNumbers
andbigNumberStrings
options.These are just ideas, so any feedback would be appreciated 😄
Ref
The text was updated successfully, but these errors were encountered: