File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -140,10 +140,20 @@ function SelectQuery(Dialect) {
140140 for ( j = 0 ; j < sql . from [ i ] . select . length ; j ++ ) {
141141 str = sql . from [ i ] . select [ j ] . f + "(" ;
142142
143- if ( sql . from . length == 1 ) {
144- str += ( sql . from [ i ] . select [ j ] . c ? Dialect . escapeId ( sql . from [ i ] . select [ j ] . c ) : "*" ) ;
143+ if ( sql . from [ i ] . select [ j ] . c && ! Array . isArray ( sql . from [ i ] . select [ j ] . c ) ) {
144+ sql . from [ i ] . select [ j ] . c = [ sql . from [ i ] . select [ j ] . c ] ;
145+ }
146+
147+ if ( Array . isArray ( sql . from [ i ] . select [ j ] . c ) ) {
148+ str += sql . from [ i ] . select [ j ] . c . map ( function ( el ) {
149+ if ( sql . from . length == 1 ) {
150+ return Dialect . escapeId ( el ) ;
151+ } else {
152+ return Dialect . escapeId ( sql . from [ i ] . a , el ) ;
153+ }
154+ } ) . join ( ", " ) ;
145155 } else {
146- str += ( sql . from [ i ] . select [ j ] . c ? Dialect . escapeId ( sql . from [ i ] . a , sql . from [ i ] . select [ j ] . c ) : "*" ) ;
156+ str += "*" ;
147157 }
148158
149159 str += ")" ;
Original file line number Diff line number Diff line change @@ -15,3 +15,8 @@ assert.equal(
1515 common . Select ( ) . from ( 'table1' ) . avg ( ) . max ( 'col1' ) . min ( 'col2' ) . build ( ) ,
1616 "SELECT AVG(MAX(`col1`)), MIN(`col2`) FROM `table1`"
1717) ;
18+
19+ assert . equal (
20+ common . Select ( ) . from ( 'table1' ) . avg ( ) . max ( [ 'col1' , 'col2' ] ) . min ( 'col3' ) . build ( ) ,
21+ "SELECT AVG(MAX(`col1`, `col2`)), MIN(`col3`) FROM `table1`"
22+ ) ;
You can’t perform that action at this time.
0 commit comments