|
|
@ -175,7 +175,7 @@ class Xsql { |
|
|
|
|
|
|
|
|
|
|
|
getGroupByClause(_groupby, tableName, queryParamsObj) { |
|
|
|
getGroupByClause(_groupby, tableName, queryParamsObj) { |
|
|
|
|
|
|
|
|
|
|
|
if(_groupby){ |
|
|
|
if (_groupby) { |
|
|
|
queryParamsObj.query += ' group by ' + _groupby + ' ' |
|
|
|
queryParamsObj.query += ' group by ' + _groupby + ' ' |
|
|
|
return _groupby |
|
|
|
return _groupby |
|
|
|
} |
|
|
|
} |
|
|
@ -186,7 +186,7 @@ class Xsql { |
|
|
|
|
|
|
|
|
|
|
|
if (_having) { |
|
|
|
if (_having) { |
|
|
|
|
|
|
|
|
|
|
|
let whereClauseObj = whereHelp.getConditionClause(_having,'having') |
|
|
|
let whereClauseObj = whereHelp.getConditionClause(_having, 'having') |
|
|
|
|
|
|
|
|
|
|
|
if (whereClauseObj.err === 0) { |
|
|
|
if (whereClauseObj.err === 0) { |
|
|
|
queryParamsObj.query = queryParamsObj.query + ' having ' + whereClauseObj.query; |
|
|
|
queryParamsObj.query = queryParamsObj.query + ' having ' + whereClauseObj.query; |
|
|
@ -244,11 +244,23 @@ class Xsql { |
|
|
|
return orderBy |
|
|
|
return orderBy |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getColumnsForSelectStmtWithGrpBy(reqQueryParams, tableName) { |
|
|
|
getColumnsForSelectStmtWithGrpBy(reqQueryParams, tableName, queryParamsObj) { |
|
|
|
return reqQueryParams._groupby + ',count(1) as _count' |
|
|
|
|
|
|
|
|
|
|
|
let grpByCols = reqQueryParams._groupby.split(','); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < grpByCols.length; ++i) { |
|
|
|
|
|
|
|
if (i) { |
|
|
|
|
|
|
|
queryParamsObj.query += ',' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
queryParamsObj.query += ' ??' |
|
|
|
|
|
|
|
queryParamsObj.params.push(grpByCols[i]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queryParamsObj.query += ',count(1) as _count ' |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getColumnsForSelectStmt(tableName, reqQueryParams) { |
|
|
|
getColumnsForSelectStmt(tableName, reqQueryParams, queryParamsObj) { |
|
|
|
|
|
|
|
|
|
|
|
let table = this.metaDb.tables[tableName]; |
|
|
|
let table = this.metaDb.tables[tableName]; |
|
|
|
let cols = []; |
|
|
|
let cols = []; |
|
|
@ -259,6 +271,7 @@ class Xsql { |
|
|
|
if ('_fields' in reqQueryParams) { |
|
|
|
if ('_fields' in reqQueryParams) { |
|
|
|
_fieldsInQuery = reqQueryParams['_fields'].split(',') |
|
|
|
_fieldsInQuery = reqQueryParams['_fields'].split(',') |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
queryParamsObj.query += ' * ' |
|
|
|
return " * "; |
|
|
|
return " * "; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -285,6 +298,14 @@ class Xsql { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < cols.length; ++i) { |
|
|
|
|
|
|
|
if (i) { |
|
|
|
|
|
|
|
queryParamsObj.query += ',' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
queryParamsObj.query += '??' |
|
|
|
|
|
|
|
queryParamsObj.params.push(cols[i]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return cols.join(',') |
|
|
|
return cols.join(',') |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|