mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-12 16:10:30 +02:00
fix(editor): Paginate through all data tables when checking name collisions
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
af6cbe4d85
commit
4b7951218c
|
|
@ -133,16 +133,26 @@ export const useDataTableStore = defineStore(DATA_TABLE_STORE, () => {
|
|||
projectId: string,
|
||||
): Promise<string> => {
|
||||
const MAX_NAME_LENGTH = 128;
|
||||
const PAGE_SIZE = 250;
|
||||
const trimmed = baseName.trim().slice(0, MAX_NAME_LENGTH).trim();
|
||||
if (!trimmed || !projectId) return trimmed;
|
||||
|
||||
const response = await fetchDataTablesApi(
|
||||
rootStore.restApiContext,
|
||||
projectId,
|
||||
{ skip: 0, take: 100 },
|
||||
{ name: trimmed },
|
||||
);
|
||||
const existingNames = new Set(response.data.map((t) => t.name.toLowerCase()));
|
||||
const existingNames = new Set<string>();
|
||||
let skip = 0;
|
||||
while (true) {
|
||||
const response = await fetchDataTablesApi(
|
||||
rootStore.restApiContext,
|
||||
projectId,
|
||||
{ skip, take: PAGE_SIZE },
|
||||
{ name: trimmed },
|
||||
);
|
||||
for (const t of response.data) {
|
||||
existingNames.add(t.name.toLowerCase());
|
||||
}
|
||||
skip += response.data.length;
|
||||
if (response.data.length < PAGE_SIZE || skip >= response.count) break;
|
||||
}
|
||||
|
||||
if (!existingNames.has(trimmed.toLowerCase())) return trimmed;
|
||||
|
||||
const buildCandidate = (n: number): string => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user