fix: revert changes when the value is the same as old (#44196)

## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Revert changes when the value is the same as the old value

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
This commit is contained in:
Ali Waseem
2026-03-26 00:39:37 -06:00
committed by GitHub
parent 3debd400a6
commit 2b419fcb1a
3 changed files with 179 additions and 4 deletions

View File

@@ -1,13 +1,16 @@
import { isEqual } from 'lodash'
import { isPendingAddRow } from '../types'
import { generateTableChangeKey, rowMatchesIdentifiers } from './queueOperationUtils'
import { tryParseJson } from '@/lib/helpers'
import {
type NewDeleteRowOperation,
type NewEditCellContentOperation,
isDeleteRowOperation,
isEditCellContentOperation,
NewQueuedOperation,
QueuedOperation,
QueuedOperationType,
isDeleteRowOperation,
isEditCellContentOperation,
type NewDeleteRowOperation,
type NewEditCellContentOperation,
} from '@/state/table-editor-operation-queue.types'
export type DeleteConflictResult =
@@ -165,6 +168,17 @@ export function upsertOperation(
existingOp.type === QueuedOperationType.EDIT_CELL_CONTENT
) {
queuedOperation.payload.oldValue = existingOp.payload.oldValue
const { oldValue, newValue } = queuedOperation.payload
// [Joshen] These comparisons by data type are because of how the table editor renders the values
if (
(typeof oldValue === 'number' && Number(oldValue) === Number(newValue)) ||
(typeof newValue === 'object' && isEqual(tryParseJson(oldValue), newValue)) ||
oldValue === newValue
) {
updatedOperations.splice(existingOpIndex, 1)
return { operations: updatedOperations }
}
}
updatedOperations[existingOpIndex] = queuedOperation