From dc464e54dc9db54ab5d51a83a882cbf6248d025f Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Fri, 25 Aug 2023 12:34:16 +0800 Subject: [PATCH] Fix comparison logic specifically for datetime values in generateUpdateRowPayload --- .../SidePanelEditor/RowEditor/RowEditor.utils.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts index 8d4a239a9863e..0e3c82dd98329 100644 --- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts +++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/RowEditor.utils.ts @@ -198,9 +198,18 @@ export const generateUpdateRowPayload = (originalRow: any, field: RowField[]) => const payload = {} as any const properties = Object.keys(rowObject) properties.forEach((property) => { - if (!isEqual(originalRow[property], rowObject[property])) { + const type = field.find((x) => x.name === property)?.format + if (type !== undefined && DATETIME_TYPES.includes(type)) { + // Just to ensure that the value are in the correct and consistent format for value comparison + const originalFormatted = convertPostgresDatetimeToInputDatetime(type, originalRow[property]) + const originalFormattedOut = convertInputDatetimeToPostgresDatetime(type, originalFormatted) + if (originalFormattedOut !== rowObject[property]) { + payload[property] = rowObject[property] + } + } else if (!isEqual(originalRow[property], rowObject[property])) { payload[property] = rowObject[property] } }) + return payload }