Skip to content

Commit 6e2f973

Browse files
adjust column naming strategy
1 parent 9796ce3 commit 6e2f973

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

  • apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/column-sidebar

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/column-sidebar/column-sidebar.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,21 @@ function deriveOutputColumnName(
7373
path: string,
7474
taken: Set<string>
7575
): string {
76-
const base = slugifyColumnName(`${blockName}_${path}`)
77-
if (!taken.has(base)) return base
76+
// Try the bare path first — short and reads as the source field. Only escalate
77+
// to longer names on collision so the common case stays clean.
78+
const candidates = [
79+
slugifyColumnName(path),
80+
slugifyColumnName(`${blockName}_${path}`),
81+
]
82+
for (const c of candidates) {
83+
if (!taken.has(c)) return c
84+
}
85+
const last = candidates[candidates.length - 1]
7886
for (let i = 2; i < 1000; i++) {
79-
const candidate = `${base}_${i}`
87+
const candidate = `${last}_${i}`
8088
if (!taken.has(candidate)) return candidate
8189
}
82-
return `${base}_${Date.now()}`
90+
return `${last}_${Date.now()}`
8391
}
8492

8593
const OUTPUT_VALUE_SEPARATOR = '::'

0 commit comments

Comments
 (0)