diff --git a/backend/zeno_backend/database/insert.py b/backend/zeno_backend/database/insert.py index b9f5c5c2..e5b534cf 100644 --- a/backend/zeno_backend/database/insert.py +++ b/backend/zeno_backend/database/insert.py @@ -640,25 +640,18 @@ async def all_slices_for_column( folder_id=None if folder_id is None else folder_id[0], ) await cur.execute( - sql.SQL( - "SELECT id FROM slices WHERE name={} AND project_uuid={};" - ).format(slice.slice_name, project) + "INSERT INTO slices (name, filter, project_uuid, folder_id) " + "VALUES (%s,%s,%s,%s) RETURNING id;", + [ + slice.slice_name, + json.dumps(slice.filter_predicates, cls=PredicatesEncoder), + project, + slice.folder_id, + ], ) - exists = await cur.fetchall() - if len(exists) == 0: - await cur.execute( - "INSERT INTO slices (name, filter, project_uuid, folder_id) " - "VALUES (%s,%s,%s,%s) RETURNING id;", - [ - slice.slice_name, - json.dumps(slice.filter_predicates, cls=PredicatesEncoder), - project, - slice.folder_id, - ], - ) - id = await cur.fetchone() - if id is not None: - ids.append(id[0]) + id = await cur.fetchone() + if id is not None: + ids.append(id[0]) return ids diff --git a/frontend/src/lib/components/metadata/Slices.svelte b/frontend/src/lib/components/metadata/Slices.svelte index ea61c785..400f7bf9 100644 --- a/frontend/src/lib/components/metadata/Slices.svelte +++ b/frontend/src/lib/components/metadata/Slices.svelte @@ -61,7 +61,7 @@ {#each $folders as folder} {/each} - {#each $slices.filter((s) => s.folderId === null || s.folderId === undefined) as s (s.sliceName)} + {#each $slices.filter((s) => s.folderId === null || s.folderId === undefined) as s (s.id)} {/each} diff --git a/frontend/src/lib/components/popups/SlicePopup.svelte b/frontend/src/lib/components/popups/SlicePopup.svelte index 40d8e03e..5285713d 100644 --- a/frontend/src/lib/components/popups/SlicePopup.svelte +++ b/frontend/src/lib/components/popups/SlicePopup.svelte @@ -30,7 +30,6 @@ let error: string | undefined = undefined; // Track original settings when editing. - let originalName = ''; let originalPredicates; $: isValidPredicates = checkValidPredicates(predicateGroup.predicates); @@ -81,7 +80,6 @@ sliceName = sliceToEdit.sliceName; predicateGroup = sliceToEdit.filterPredicates; folderId = sliceToEdit.folderId === null ? undefined : sliceToEdit.folderId; - originalName = sliceName; // deep copy of predicate group to avoid sharing nested objects originalPredicates = JSON.parse(JSON.stringify(predicateGroup)); @@ -217,32 +215,17 @@ deletePredicate(-1)} bind:predicateGroup />
{#if checkNominalSinglePredicateNoEntry(predicateGroup)} - {:else} - {/if} - {#if (!sliceToEdit && $slices.some((slice) => slice.sliceName === sliceName)) || (sliceToEdit && originalName !== sliceName && $slices.some((slice) => slice.sliceName === sliceName))} -

slice already exists

- {/if}
{#if error}