File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -396,7 +396,10 @@ class ResultSet extends Command {
396396 // [ {"1": 1} ], //rows
397397 // [ColumnDefinition] //meta
398398 // ]
399- if ( this . _responseIndex === 0 ) this . _meta = [ ] ;
399+ if ( ! this . _meta ) {
400+ this . _meta = new Array ( this . _responseIndex ) ;
401+ }
402+
400403 this . _meta [ this . _responseIndex ] = this . _columns ;
401404
402405 if ( info . status & ServerStatus . MORE_RESULTS_EXISTS || this . isOutParameter ) {
Original file line number Diff line number Diff line change @@ -16,6 +16,35 @@ describe('Pool', () => {
1616 //eat
1717 } ) ;
1818 } ) ;
19+
20+ it ( 'pool metaAsArray' , function ( done ) {
21+ const pool = base . createPool ( {
22+ metaAsArray : true ,
23+ multipleStatements : true ,
24+ connectionLimit : 1
25+ } ) ;
26+ pool
27+ . query ( {
28+ sql :
29+ 'DROP TABLE IF EXISTS t; ' +
30+ 'CREATE TABLE t (i int);\n' +
31+ 'INSERT INTO t(i) VALUES (1);\n' +
32+ 'SELECT i FROM t; ' ,
33+ timeout : 3000
34+ } )
35+ . then ( res => {
36+ assert . equal ( 2 , res . length ) ;
37+ assert . equal ( 4 , res [ 0 ] . length ) ;
38+ assert . equal ( 4 , res [ 1 ] . length ) ;
39+ assert . equal ( 'i' , res [ 1 ] [ 3 ] [ 0 ] . name ( ) ) ;
40+ pool . end ( ) ;
41+ done ( ) ;
42+ } )
43+ . catch ( err => {
44+ pool . end ( ) ;
45+ done ( err ) ;
46+ } ) ;
47+ } ) ;
1948
2049 it ( 'pool escape' , function ( ) {
2150 if ( ! base . utf8Collation ( ) ) this . skip ( ) ;
You can’t perform that action at this time.
0 commit comments