diff --git a/models/table.js b/models/table.js index 742314458..30d17fb5c 100644 --- a/models/table.js +++ b/models/table.js @@ -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; } diff --git a/test/models/table/aggregation/max.js b/test/models/table/aggregation/max.js index 4ac811496..829e30caf 100644 --- a/test/models/table/aggregation/max.js +++ b/test/models/table/aggregation/max.js @@ -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); + }); });