From 74637ae74f82560045e6086997e5239fd99cf5de Mon Sep 17 00:00:00 2001 From: ulriklystbaek Date: Wed, 6 Jan 2021 11:11:38 +0100 Subject: [PATCH 1/2] Update RowDataPacket.js Make it possible for getting column by its index (just like field list). This way you can implement your own unique strategy outside the module. Usage: conn.query({ sql, nestTables: [] }, function(error, results, fields) { } ); --- lib/protocol/packets/RowDataPacket.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/protocol/packets/RowDataPacket.js b/lib/protocol/packets/RowDataPacket.js index b8ec4b895..2a40ed39e 100644 --- a/lib/protocol/packets/RowDataPacket.js +++ b/lib/protocol/packets/RowDataPacket.js @@ -39,7 +39,9 @@ function parse(parser, fieldPackets, typeCast, nestTables, connection) { : parser.parseLengthCodedString() ); } - if (typeof nestTables === 'string' && nestTables.length) { + if (Array.isArray(nestTables)) { + this[i] = value; + } else if (typeof nestTables === 'string' && nestTables.length) { this[fieldPacket.table + nestTables + fieldPacket.name] = value; } else if (nestTables) { this[fieldPacket.table] = this[fieldPacket.table] || {}; From e4f9c0588454999889ad02d48bea4a4065a9e12b Mon Sep 17 00:00:00 2001 From: ulriklystbaek Date: Wed, 6 Jan 2021 11:22:51 +0100 Subject: [PATCH 2/2] Update RowDataPacket.js Support prior to 0.10 --- lib/protocol/packets/RowDataPacket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/protocol/packets/RowDataPacket.js b/lib/protocol/packets/RowDataPacket.js index 2a40ed39e..4dffd7d63 100644 --- a/lib/protocol/packets/RowDataPacket.js +++ b/lib/protocol/packets/RowDataPacket.js @@ -39,7 +39,7 @@ function parse(parser, fieldPackets, typeCast, nestTables, connection) { : parser.parseLengthCodedString() ); } - if (Array.isArray(nestTables)) { + if (nestTables instanceof Array) { this[i] = value; } else if (typeof nestTables === 'string' && nestTables.length) { this[fieldPacket.table + nestTables + fieldPacket.name] = value;