@@ -28,6 +28,7 @@ import { gkey, SectionTitle, AdqlUI, BasicUI} from 'firefly/ui/tap/TableSelectVi
2828
2929
3030const SERVICE_TIP = 'Select a TAP service, or type to enter the URL of any other TAP service' ;
31+ const ADQL_LINE_LENGTH = 100 ;
3132
3233//-------------
3334//-------------
@@ -338,7 +339,24 @@ function getAdqlQuery(showErrors= true) {
338339 if ( adqlFragment . where ) {
339340 constraints += ( addAnd ? ' AND ' : '' ) + `(${ adqlFragment . where } )` ;
340341 }
341- const selcols = adqlFragment . selcols || '*' ;
342+ let selcols = adqlFragment . selcols || '*' ;
343+
344+ // If the line is long, rebuild the line from array of column names
345+ // breaking at ADQL_LINE_LENGTH
346+ if ( selcols . length > ADQL_LINE_LENGTH ) {
347+ selcols = '' ;
348+ let line = adqlFragment . selcolsArray [ 0 ] ;
349+ const colsCopy = adqlFragment . selcolsArray . slice ( 1 ) ;
350+ colsCopy . forEach ( ( value ) => {
351+ const nextColumn = ',' + value ;
352+ if ( ( line + nextColumn ) . length > ADQL_LINE_LENGTH ) {
353+ selcols += line + '\n' ;
354+ line = ' ' ;
355+ }
356+ line += nextColumn ;
357+ } ) ;
358+ selcols += line ;
359+ }
342360
343361 if ( constraints ) {
344362 constraints = `WHERE ${ constraints } ` ;
@@ -347,5 +365,5 @@ function getAdqlQuery(showErrors= true) {
347365 // if we use TOP when maxrec is set `${maxrec ? `TOP ${maxrec} `:''}`,
348366 // overflow indicator will not be included with the results
349367 // and we will not know if the results were truncated
350- return `SELECT ${ selcols } FROM ${ tableName } ${ constraints } ` ;
368+ return `SELECT ${ selcols } \nFROM ${ tableName } \n ${ constraints } ` ;
351369}
0 commit comments