Bug #100255 xdevapi for node: result for columns of type set contain only 1 value of the set
Submitted: 19 Jul 2020 5:47 Modified: 30 Jul 2020 21:23
Reporter: Dieter Rehbein Email Updates:
Status: Closed Impact on me:
None 
Category:Connector for Node.js Severity:S2 (Serious)
Version: OS:MacOS (OSX Catalina)
Assigned to: CPU Architecture:Any

[19 Jul 2020 5:47] Dieter Rehbein
Description:
If an sql-query is executed, wich returns the content of a column with type SET, the result contains only 1 value of the set.

How to repeat:
1) Create a table, which contains a column of type set:

CREATE TABLE T_shirt 
   (
   id  int NOT NULL AUTO_INCREMENT,
   size SET('S', 'M', 'L', 'XL', 'XXL'),
   PRIMARY KEY(id)
   )

2) INSERT data into the table

INSERT INTO t_shirt(size) VALUES ('S,L,XXL');

3) SELECT data using the xdevapi:

session.sql('SELECT * FROM t_shirt').execute().then(result => {

   const rows = result.fetchAll();

   const tshirtSize = rows[0][1]; 
   console.log(tshirtSize);  // prints ['S'].  The values L and XXL are missing

});
[19 Jul 2020 7:50] Dieter Rehbein
Tested with @mysql/xdevapi versions 8.0.19 and 8.0.21 (8.0.21 was the latest version at the time when this bug was submitted)
[21 Jul 2020 8:58] MySQL Verification Team
Hi,

Verified as described. Looks like some object mapping is not happening ok :(

Thanks for the report

Good health
Bogdan

p.s.

[arhimed@localdev msb_ndb8_0_20]$ cat b100255.js
const mysqlx = require('@mysql/xdevapi');

const options = { host: 'localhost', user: 'msandbox', password: 'msandbox', port: '18020', ssl: true };

 mysqlx.getSession(options)
  .then((session) => {
    console.log(session.inspect());

    session.sql('SELECT id, concat(size, " ") FROM test.t_shirt').execute().then(result => { //convert to string
//    session.sql('SELECT * FROM test.t_shirt').execute().then(result => {
       const rows = result.fetchAll();
       const tshirtSize = rows[0][1];
       console.log(tshirtSize);

       console.log(rows);

    });

  });
[arhimed@localdev msb_ndb8_0_20]$
[arhimed@localdev msb_ndb8_0_20]$ node b100255.js
{
  auth: 'PLAIN',
  pooling: false,
  ssl: true,
  host: 'localhost',
  user: 'msandbox',
  port: '18020',
  dbUser: 'msandbox',
  socket: undefined
}
[ 'S' ]
[ [ 1, [ 'S' ] ] ]

^C
[arhimed@localdev msb_ndb8_0_20]$ vi b100255.js
[arhimed@localdev msb_ndb8_0_20]$ node b100255.js
{
  auth: 'PLAIN',
  pooling: false,
  ssl: true,
  host: 'localhost',
  user: 'msandbox',
  port: '18020',
  dbUser: 'msandbox',
  socket: undefined
}
S,L,XXL
[ [ 1, 'S,L,XXL ' ] ]
^C
[arhimed@localdev msb_ndb8_0_20]$
[30 Jul 2020 21:23] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connector/Node.js 8.0.22 release, and here's the proposed changelog entry from the documentation team:

Fetched results from a SET column would only contain one value from the
set.

Thank you for the bug report.