Skip to content

Commit

Permalink
Line Chart - Fix ambiguous groupBy field for MySQL databases (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudbesnier authored and SeyZ committed Dec 14, 2016
1 parent ba10094 commit a14d4c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Change Log

## [Unreleased]
### Fixed
- Line Chart - Fix ambiguous groupBy field for MySQL databases.

## RELEASE 0.5.2 - 2016-12-13
### Fixed
Expand Down
9 changes: 5 additions & 4 deletions services/line-stat-getter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ function LineStatGetter(model, params, opts) {
}

function getGroupByDateInterval() {
var column = params['group_by_date_field'];

if (isMysql()) {
var column = getGroupByDateField();

switch (timeRange) {
case 'day':
return [
Expand All @@ -37,9 +37,10 @@ function LineStatGetter(model, params, opts) {
'date'
];
case 'week':
var columnFormated = '`' + column.replace('.', '`.`') + '`';
return [
opts.sequelize.literal('DATE_FORMAT(DATE_SUB(' + column + ', ' +
'INTERVAL ((7 + WEEKDAY(' + column + ')) % 7) DAY), ' +
opts.sequelize.literal('DATE_FORMAT(DATE_SUB(' + columnFormated +
', INTERVAL ((7 + WEEKDAY(' + columnFormated + ')) % 7) DAY), ' +
'\'%Y-%m-%d 00:00:00\')'),
'date'
];
Expand Down

0 comments on commit a14d4c5

Please sign in to comment.