Skip to content

Commit

Permalink
fix: bug column name when sequelize model mapping attribute has field…
Browse files Browse the repository at this point in the history
… option

access the schema field columnName instead access directly through the fieldName.

Closed ForestAdmin#282
Closed ForestAdmin#273
  • Loading branch information
Jekiwijaya committed Jul 2, 2019
1 parent 7bf8c8c commit a3c7a0c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services/line-stat-getter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a3c7a0c

Please sign in to comment.