@ -139,6 +139,7 @@ class Xsql {
}
}
}
/**************** END : Cache functions ****************/
@ -954,27 +955,38 @@ class Xsql {
queryParamsObj . query = 'SELECT '
queryParamsObj . grammarErr = 0 ;
while ( 1 ) {
/**************** START : get fields ****************/
if ( req . query . _fields ) {
let fields = req . query . _fields . split ( ',' )
// from _fields to - ??, ??, ?? [col1,col2,col3]
for ( var i = 0 ; i < fields . length ; ++ i ) {
for ( var i = 0 ; i < fields . length && ( ! queryParamsObj . grammarErr ) ; ++ i ) {
if ( i ) {
queryParamsObj . query += ','
}
queryParamsObj . query += ' ?? '
queryParamsObj . params . push ( fields [ i ] )
let aliases = fields [ i ] . split ( '.' ) ;
if ( aliases . length === 2 ) {
queryParamsObj . query += 'as ' + aliases [ 0 ] + '_' + aliases [ 1 ] ;
//console.log(queryParamsObj.query);
} else {
queryParamsObj . grammarErr = 1 ;
}
}
} else {
queryParamsObj . grammarErr = 1 ;
}
queryParamsObj . query += ' * '
queryParamsObj . query += ' from '
if ( queryParamsObj . grammarErr ) {
break ;
}
queryParamsObj . query += ' from '
/**************** END : get fields ****************/
@ -983,6 +995,7 @@ class Xsql {
if ( joinTables . length < 3 ) {
//console.log('grammar error ', joinTables.length);
queryParamsObj . grammarErr = 1 ;
break ;
}
//console.log('jointables.length', joinTables);
@ -1016,29 +1029,33 @@ class Xsql {
break ;
}
//console.log('- - - - - - -');
if ( i === 0 ) {
i = i + 1
}
//console.log('index after loop', i);
}
/**************** END : get join + on ****************/
if ( queryParamsObj . grammarErr ) {
queryParamsObj . query = ''
queryParamsObj . params = [ ]
break ;
} else {
this . getWhereClause ( req . query . _where , ' ignore ' , queryParamsObj , ' where ' ) ;
this . _getGrpByHavingOrderBy ( req , 'ignore' , queryParamsObj , 5 )
//console.log('after where',queryParamsObj);
}
this . getWhereClause ( req . query . _where , ' ignore ' , queryParamsObj , ' where ' ) ;
break ;
//console.log('after where',queryParamsObj);
}
this . _getGrpByHavingOrderBy ( req , 'ignore' , queryParamsObj , 5 )
return queryParamsObj ;
if ( queryParamsObj . grammarErr ) {
queryParamsObj . query = ''
queryParamsObj . params = [ ]
}
return queryParamsObj ;
}
}