Home / Function/ generateTableChangeKey() — supabase Function Reference

generateTableChangeKey() — supabase Function Reference

Architecture documentation for the generateTableChangeKey() function in queueOperationUtils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  3722bac8_b656_267a_d2e2_c3ec91d59be4["generateTableChangeKey()"]
  0744d7d4_22bb_aeff_2a10_29a93f5cb7d7["resolveDeleteRowConflicts()"]
  0744d7d4_22bb_aeff_2a10_29a93f5cb7d7 -->|calls| 3722bac8_b656_267a_d2e2_c3ec91d59be4
  9b281136_50fc_db48_fd92_e34bfb615e42["upsertOperation()"]
  9b281136_50fc_db48_fd92_e34bfb615e42 -->|calls| 3722bac8_b656_267a_d2e2_c3ec91d59be4
  style 3722bac8_b656_267a_d2e2_c3ec91d59be4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/grid/utils/queueOperationUtils.ts lines 25–53

export function generateTableChangeKey(
  operation: NewQueuedOperation | EditCellKeyOperation
): string {
  if (operation.type === QueuedOperationType.EDIT_CELL_CONTENT) {
    const { columnName, rowIdentifiers } = operation.payload
    const rowIdentifiersKey = Object.entries(rowIdentifiers)
      .sort(([a], [b]) => a.localeCompare(b))
      .map(([key, value]) => `${key}:${value}`)
      .join('|')
    return `${operation.type}:${operation.tableId}:${columnName}:${rowIdentifiersKey}`
  }

  if (operation.type === QueuedOperationType.ADD_ROW) {
    return `${operation.type}:${operation.tableId}:${operation.payload.tempId}`
  }

  if (operation.type === QueuedOperationType.DELETE_ROW) {
    const { rowIdentifiers } = operation.payload
    const rowIdentifiersKey = Object.entries(rowIdentifiers)
      .sort(([a], [b]) => a.localeCompare(b))
      .map(([key, value]) => `${key}:${value}`)
      .join('|')
    return `${operation.type}:${operation.tableId}:${rowIdentifiersKey}`
  }

  // Exhaustive check - TypeScript will error if we miss a case
  const _exhaustiveCheck: never = operation
  throw new Error(`Unknown operation type: ${(_exhaustiveCheck as { type: string }).type}`)
}

Subdomains

Frequently Asked Questions

What does generateTableChangeKey() do?
generateTableChangeKey() is a function in the supabase codebase.
What calls generateTableChangeKey()?
generateTableChangeKey() is called by 2 function(s): resolveDeleteRowConflicts, upsertOperation.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free