Fix creation of a new view duplicating existing filters (#9240)
Fixes #9239
This commit is contained in:
@ -13,6 +13,7 @@ import { useDestroyOneRecordMutation } from '@/object-record/hooks/useDestroyOne
|
|||||||
import { useUpdateOneRecordMutation } from '@/object-record/hooks/useUpdateOneRecordMutation';
|
import { useUpdateOneRecordMutation } from '@/object-record/hooks/useUpdateOneRecordMutation';
|
||||||
import { GraphQLView } from '@/views/types/GraphQLView';
|
import { GraphQLView } from '@/views/types/GraphQLView';
|
||||||
import { ViewFilter } from '@/views/types/ViewFilter';
|
import { ViewFilter } from '@/views/types/ViewFilter';
|
||||||
|
import { v4 } from 'uuid';
|
||||||
|
|
||||||
export const usePersistViewFilterRecords = () => {
|
export const usePersistViewFilterRecords = () => {
|
||||||
const { objectMetadataItem } = useObjectMetadataItem({
|
const { objectMetadataItem } = useObjectMetadataItem({
|
||||||
@ -49,7 +50,7 @@ export const usePersistViewFilterRecords = () => {
|
|||||||
mutation: createOneRecordMutation,
|
mutation: createOneRecordMutation,
|
||||||
variables: {
|
variables: {
|
||||||
input: {
|
input: {
|
||||||
id: viewFilter.id,
|
id: v4(),
|
||||||
fieldMetadataId: viewFilter.fieldMetadataId,
|
fieldMetadataId: viewFilter.fieldMetadataId,
|
||||||
viewId: view.id,
|
viewId: view.id,
|
||||||
value: viewFilter.value,
|
value: viewFilter.value,
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import {
|
|||||||
TimeoutError,
|
TimeoutError,
|
||||||
UserInputError,
|
UserInputError,
|
||||||
} from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
|
} from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
|
||||||
|
import { isDefined } from 'src/utils/is-defined';
|
||||||
|
|
||||||
export const workspaceQueryRunnerGraphqlApiExceptionHandler = (
|
export const workspaceQueryRunnerGraphqlApiExceptionHandler = (
|
||||||
error: Error,
|
error: Error,
|
||||||
@ -49,7 +50,11 @@ export const workspaceQueryRunnerGraphqlApiExceptionHandler = (
|
|||||||
return fieldMetadata?.label;
|
return fieldMetadata?.label;
|
||||||
});
|
});
|
||||||
|
|
||||||
const columnNames = affectedColumns?.join(', ');
|
if (!isDefined(affectedColumns)) {
|
||||||
|
throw new UserInputError(`A duplicate entry was detected`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const columnNames = affectedColumns.join(', ');
|
||||||
|
|
||||||
if (affectedColumns?.length === 1) {
|
if (affectedColumns?.length === 1) {
|
||||||
throw new UserInputError(
|
throw new UserInputError(
|
||||||
|
|||||||
Reference in New Issue
Block a user