Browse Source

fix: make sure at least one pk is valid while extracting composite pk

pull/8371/head
mertmit 7 months ago
parent
commit
d24de3ffe1
  1. 11
      packages/nc-gui/utils/dataUtils.ts

11
packages/nc-gui/utils/dataUtils.ts

@ -5,11 +5,12 @@ import type { Row } from '~/lib'
export const extractPkFromRow = (row: Record<string, any>, columns: ColumnType[]) => { export const extractPkFromRow = (row: Record<string, any>, columns: ColumnType[]) => {
if (!row || !columns) return null if (!row || !columns) return null
return columns
.filter((c) => c.pk) const pkColumns = columns.filter((c) => c.pk)
.map((c) => row?.[c.title as string])
.filter((v) => v) if (!pkColumns.some((c) => row?.[c.title as string])) return null
.join('___')
return pkColumns.map((c) => row?.[c.title as string]).join('___')
} }
export const rowPkData = (row: Record<string, any>, columns: ColumnType[]) => { export const rowPkData = (row: Record<string, any>, columns: ColumnType[]) => {

Loading…
Cancel
Save