Skip to content

Commit

Permalink
Merge pull request #219 from afontainec/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
afontainec committed Jun 14, 2021
2 parents 655ed0c + 48ffa90 commit a9c262b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion models/table.js
Expand Up @@ -105,7 +105,8 @@ class Table {
const nonGroupedBy = result.length === 1 && Object.keys(result[0]).length === 1;
if (nonGroupedBy) {
const key = Object.keys(result[0])[0];
return parseInt(result[0][key] || 0, 10);
const asNumber = parseInt(result[0][key] || 0, 10);
return Number.isNaN(asNumber) ? result[0][key] : asNumber;
}
return result;
}
Expand Down
7 changes: 7 additions & 0 deletions test/models/table/aggregation/max.js
Expand Up @@ -21,4 +21,11 @@ describe('TABLE GATEWAY: max', () => { // eslint-disable-line max-lines-per-func
const result = await Coffee.max(column, search, options);
assert.equal(result, 110);
});

it('type is not number', async () => {
const column = 'created_at';
const options = { };
const result = await Coffee.max(column, {}, options);
assert.isNotNaN(result);
});
});

0 comments on commit a9c262b

Please sign in to comment.