diff --git a/src/services/line-stat-getter.js b/src/services/line-stat-getter.js index 23153455..56aae138 100644 --- a/src/services/line-stat-getter.js +++ b/src/services/line-stat-getter.js @@ -17,12 +17,16 @@ function LineStatGetter(model, params, options) { // cannot be '*'. const fieldName = params.aggregate_field || schema.primaryKeys[0] || schema.fields[0].field; - return `${schema.name}.${fieldName}`; + const schemaField = schema.fields.find(schemaField => schemaField.field === fieldName); + const columnName = schemaField ? schemaField.columnName : fieldName; + return `${schema.name}.${columnName}`; } function getGroupByDateField() { const fieldName = params.group_by_date_field; - return `${schema.name}.${fieldName}`; + const schemaField = schema.fields.find(schemaField => schemaField.field === fieldName); + const columnName = schemaField ? schemaField.columnName : fieldName; + return `${schema.name}.${columnName}`; } const groupByDateField = getGroupByDateField();