|
1673 | 1673 | // don't add a column name in if it's already there
|
1674 | 1674 | // this can be the case for multi-edit
|
1675 | 1675 | // and if the data is unchanged, no need to add the column name to the projections list
|
1676 |
| - // NOTE: This doesn't properly verify if date/timestamp/timestamptz values were changed |
1677 |
| - if (columnProjections.indexOf(colName) === -1) { |
1678 |
| - var typename = colType.rootName; |
1679 |
| - var compareWithMoment = typename === 'date' || typename === 'timestamp' || typename === 'timestamptz'; |
1680 |
| - if (compareWithMoment) { |
1681 |
| - var moment = module._moment; |
1682 |
| - var formats = module._dataFormats; |
1683 |
| - |
1684 |
| - // default to DATE format, if timestamp or timestamptz, change the format used |
1685 |
| - var formatToUse = formats.DATE; |
1686 |
| - if (typename === 'timestamp') { |
1687 |
| - formatToUse = formats.TIMESTAMP; |
1688 |
| - } else if (typename === 'timestamptz') { |
1689 |
| - formatToUse = formats.DATETIME.return; |
1690 |
| - } |
1691 |
| - |
1692 |
| - var oldVal = moment(oldData[colName], formatToUse, true).format(formatToUse); |
1693 |
| - var newVal = moment(newData[colName], formatToUse, true).format(formatToUse); |
1694 |
| - |
1695 |
| - if (oldVal != newVal) columnProjections.push(colName); |
1696 |
| - } else if ( (oldData[colName] != newData[colName]) ) { |
| 1676 | + if (columnProjections.indexOf(colName) !== -1) return; |
| 1677 | + |
| 1678 | + var oldVal = oldData[colName] |
| 1679 | + var newVal = newData[colName] |
| 1680 | + |
| 1681 | + var typename = colType.rootName; |
| 1682 | + var compareWithMoment = typename === 'date' || typename === 'timestamp' || typename === 'timestamptz'; |
| 1683 | + // test with moment if datetime column type and one of the 2 values are defined |
| 1684 | + // NOTE: moment will test 2 null values as different even though they are both null |
| 1685 | + if (compareWithMoment && (oldVal || newVal)) { |
| 1686 | + var moment = module._moment; |
| 1687 | + |
| 1688 | + var oldMoment = moment(oldData[colName]) |
| 1689 | + var newMoment = moment(newData[colName]) |
| 1690 | + |
| 1691 | + if (!oldMoment.isSame(newMoment)) { |
1697 | 1692 | columnProjections.push(colName);
|
1698 | 1693 | }
|
| 1694 | + } else if (oldData[colName] != newData[colName]) { |
| 1695 | + columnProjections.push(colName); |
1699 | 1696 | }
|
1700 | 1697 | };
|
1701 | 1698 |
|
|
0 commit comments