Skip to content

Commit

Permalink
fix: leave null timestamp unformatted in view results table (apache#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro authored Jul 14, 2020
1 parent 266238c commit 7eb0048
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 8 additions & 4 deletions superset-frontend/spec/javascripts/utils/common_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,16 @@ describe('utils/common', () => {
});
it('changes formatting of temporal column', () => {
const originalData = [
{ __timestamp: 1594285437771, column1: 'lorem' },
{ __timestamp: 1594285441675, column1: 'ipsum' },
{ __timestamp: null, column1: 'lorem' },
{ __timestamp: 0, column1: 'ipsum' },
{ __timestamp: 1594285437771, column1: 'dolor' },
{ __timestamp: 1594285441675, column1: 'sit' },
];
const expectedData = [
{ __timestamp: '2020-07-09 09:03:57', column1: 'lorem' },
{ __timestamp: '2020-07-09 09:04:01', column1: 'ipsum' },
{ __timestamp: null, column1: 'lorem' },
{ __timestamp: '1970-01-01 00:00:00', column1: 'ipsum' },
{ __timestamp: '2020-07-09 09:03:57', column1: 'dolor' },
{ __timestamp: '2020-07-09 09:04:01', column1: 'sit' },
];
expect(applyFormattingToTabularData(originalData)).toEqual(expectedData);
});
Expand Down
8 changes: 6 additions & 2 deletions superset-frontend/src/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ export function applyFormattingToTabularData(data) {
}
return data.map(row => ({
...row,
// eslint-disable-next-line no-underscore-dangle
__timestamp: DATETIME_FORMATTER(new Date(row.__timestamp)),
/* eslint-disable no-underscore-dangle */
__timestamp:
row.__timestamp === 0 || row.__timestamp
? DATETIME_FORMATTER(new Date(row.__timestamp))
: row.__timestamp,
/* eslint-enable no-underscore-dangle */
}));
}

0 comments on commit 7eb0048

Please sign in to comment.