FredyH / MySQLOO

MySQLOO
GNU Lesser General Public License v2.1
140 stars 55 forks source link

Bigints being returned as floats #76

Closed NathanX-S closed 3 years ago

NathanX-S commented 3 years ago

LUA can't handle these numbers and instead precision is lost and the data becomes useless upon being passed through the module, can this be changed to return them as strings instead?

Kefta commented 3 years ago

This will unfortunately break a lot of code, perhaps there should be a bool argument (or more extendable, a table of settings) in the query method to alter this behaviour.

NathanX-S commented 3 years ago

That works too, just losing tons of data for no good reason is a pain in the neck. Even if it's in _mysqloolib, fine by me.

FredyH commented 3 years ago

Cast the bigint to a string in your select statement, then you can get it as a string, which retains the precision.

NathanX-S commented 3 years ago

I'd rather have this as a built in feature, as @Kefta proposed.

FredyH commented 3 years ago

I don't see how it is hard to simply add a cast to string? Adding a bool parameter to every function that queries the database would be a very big change (that complicates the api a lot because optional parameters in lua are bad) for as far as I can see no gain at all.

NathanX-S commented 3 years ago

https://github.com/tediousjs/node-mssql/issues/187 https://i.imgur.com/LFKhZ91.png This behaviour is at the very least supported across other modules and is to be expected to have. Maybe a configuration outside of the query?

Kefta commented 3 years ago

Fredy is right, the simple solution is just to cast. Numbers should always have been returned as strings but changing it now would break a ton of code.