mysqljs / mysql

A pure node.js JavaScript Client implementing the MySQL protocol.
MIT License
18.28k stars 2.52k forks source link

The BIGINT option bigNumberStrings=true ignored for results.insertId #2460

Open AgnisLV opened 3 years ago

AgnisLV commented 3 years ago

For INSERT query the last insertId is not cast to string when the auto-increment column is bigint. The bigNumberStrings is ignored and the result is returned as number. typeof results.insertId == number

dougwilson commented 3 years ago

Hi @AgnisLV in the MySQL protocol, the insertId is always returned as a BIGINT no matter the query. The bigNumberStrings is specifically around the typecasting of columns, not of the other aspects of MySQL protocol packets (like the results packet).

dougwilson commented 3 years ago

AFAIK there is no loss in the value. Can you provide a reproduction for the precision loss you are seeing so we can take a look?

AgnisLV commented 3 years ago

Sorry, I was too hasty with my last comment. It seems that if supportBigNumbers is enabled then insertId will be returned as a String when numbers are large enough. All clear now.