Skip to content

Commit f0b5ad6

Browse files
waleedlatif1claude
andcommitted
fix(tables): show toast on incompatible column type change
The server validates type compatibility and returns a clear error message (e.g. "3 row(s) have incompatible values"), but the client was silently swallowing it. Now surfaces the error via toast notification. Also moved the undo push to onSuccess so a failed type change doesn't pollute the undo stack. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a7f94a4 commit f0b5ad6

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

  • apps/sim
    • app/workspace/[workspaceId]/tables/[tableId]/components/table
    • hooks/queries

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table/table.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,15 +1624,22 @@ export function Table({
16241624

16251625
const handleChangeType = useCallback((columnName: string, newType: string) => {
16261626
const column = columnsRef.current.find((c) => c.name === columnName)
1627-
if (column) {
1628-
pushUndoRef.current({
1629-
type: 'update-column-type',
1630-
columnName,
1631-
previousType: column.type,
1632-
newType,
1633-
})
1634-
}
1635-
updateColumnMutation.mutate({ columnName, updates: { type: newType } })
1627+
const previousType = column?.type
1628+
updateColumnMutation.mutate(
1629+
{ columnName, updates: { type: newType } },
1630+
{
1631+
onSuccess: () => {
1632+
if (previousType) {
1633+
pushUndoRef.current({
1634+
type: 'update-column-type',
1635+
columnName,
1636+
previousType,
1637+
newType,
1638+
})
1639+
}
1640+
},
1641+
}
1642+
)
16361643
}, [])
16371644

16381645
const insertColumnInOrder = useCallback(

apps/sim/hooks/queries/tables.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,9 @@ export function useUpdateColumn({ workspaceId, tableId }: RowMutationContext) {
676676

677677
return res.json()
678678
},
679+
onError: (error) => {
680+
toast.error(error.message, { duration: 5000 })
681+
},
679682
onSettled: () => {
680683
invalidateTableSchema(queryClient, workspaceId, tableId)
681684
},

0 commit comments

Comments
 (0)