Skip to content

Commit

Permalink
Merge pull request supabase#16798 from supabase/fix/table-editor-row-…
Browse files Browse the repository at this point in the history
…editor-side-panel-not-comparing-datetime-fields-properly-in-generate-update-row-payload

Fix comparison logic specifically for datetime values in generateUpdateRowPayload
  • Loading branch information
joshenlim authored Aug 25, 2023
2 parents 76df911 + dc464e5 commit e54acff
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit e54acff

Please sign in to comment.