Bug #89933 mysql nodejs connector retrieve wrong data with relational tables
Submitted: 6 Mar 2018 15:46 Modified: 22 Mar 2018 7:22
Reporter: Nicolas Moreau Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector for Node.js Severity:S1 (Critical)
Version:8.0.9 OS:Microsoft Windows (windows 10)
Assigned to: CPU Architecture:Any
Tags: nodejs connector wrong data

[6 Mar 2018 15:46] Nicolas Moreau
Description:
Hi,

I wanted to create an application with nodejs (with express) and mysql document store.
I have installed the npm @mysql/xdevapi (i discovered after that npm install an 8 version but i am not sure this is the problem in the package.json)
i am using mysql 5.7.17 (i know this is not the last one)

i have one very simple table 
mysql> desc users;
+------------+------------------+------+-----+---------+----------------+
| Field      | Type             | Null | Key | Default | Extra          |
+------------+------------------+------+-----+---------+----------------+
| id         | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| last_name  | varchar(50)      | YES  |     | NULL    |                |
| first_name | varchar(50)      | YES  |     | NULL    |                |
| login      | varchar(50)      | YES  |     | NULL    |                |
+------------+------------------+------+-----+---------+----------------+

with 2 values :
mysql> select * from users;
+----+-----------+------------+--------+
| id | last_name | first_name | login  |
+----+-----------+------------+--------+
|  1 | Moreau    | Nicolas    | dellos |
|  2 | Moreau    | Nicolas    | dellos |
+----+-----------+------------+--------+

note the id...

with nodejs connector (the code is not very good)
this is the result of :

eventsCollection = schema.getTable('users').select();
    var test=eventsCollection.execute(function (item) {
      console.log(item);
    }, function(meta) {
      //console.log(meta)
      });
the results : 
[ -1, 'Moreau', 'Nicolas', 'dellos' ]
[ 1, 'Moreau', 'Nicolas', 'dellos' ]

id is wrong i have no negative value (my insert was done with SQL) and the column is unsigned

this is a big problem, but i may be wrong with the code (i am a dba more than a developer :)

primary key, auto_increment was added later, there is also a foreignkey pointing to id column from another table

If the connector return bad data, this is a big problem

How to repeat:
create table and insert data with the same model 
use nodejs connector and sql to compare...
[22 Mar 2018 7:22] Chiranjeevi Battula
Hello Nicolas Moreau,

Thank you for the bug report.
Discussed internally with developer and we concluded that this is duplicate of internally reported Bug #27570342 which is fixed as of the upcoming MySQL Connector/Node.js 8.0.11 release. 
Here's the changelog entry:  Row values for columns of any type of UNSIGNED integer (TINYINT, SMALLINT, MEDIUMINT, INT or BIGINT) were being interpreted by the connector as their SIGNED integer value counterpart.

Thanks,
Chiranjeevi.