From 57f11901bca2eedfc9cf8d436830fca7aa0b7e0e Mon Sep 17 00:00:00 2001 From: Artem Niehrieiev Date: Wed, 26 Feb 2025 12:47:52 +0000 Subject: [PATCH] Add validation for default showing table to prevent selection and exclusion in connection properties setup --- .../utils/validate-create-connection-properties-ds.ts | 3 +++ backend/src/exceptions/text/messages.ts | 2 ++ 2 files changed, 5 insertions(+) diff --git a/backend/src/entities/connection-properties/utils/validate-create-connection-properties-ds.ts b/backend/src/entities/connection-properties/utils/validate-create-connection-properties-ds.ts index 4705997e6..74ec54000 100644 --- a/backend/src/entities/connection-properties/utils/validate-create-connection-properties-ds.ts +++ b/backend/src/entities/connection-properties/utils/validate-create-connection-properties-ds.ts @@ -23,6 +23,9 @@ export async function validateCreateConnectionPropertiesDs( errors.push(Messages.TABLE_WITH_NAME_NOT_EXISTS(hiddenTable)); } } + if (hidden_tables.includes(default_showing_table)) { + errors.push(Messages.CANT_SHOW_TABLE_AND_EXCLUDE(default_showing_table)); + } } if (default_showing_table && !tablesInConnection.includes(default_showing_table)) { diff --git a/backend/src/exceptions/text/messages.ts b/backend/src/exceptions/text/messages.ts index 0b5a097fc..9abe8a1b8 100644 --- a/backend/src/exceptions/text/messages.ts +++ b/backend/src/exceptions/text/messages.ts @@ -51,6 +51,8 @@ export const Messages = { 'It seems like the value you entered for the unique field already exists in database. Please check your input and try again with a different value', CANT_LIST_AND_EXCLUDE: (fieldName: string) => `You cannot select the same field ${fieldName ? fieldName : 'names'} to list and exclude`, + CANT_SHOW_TABLE_AND_EXCLUDE: (tableName: string) => + `You cannot select the same table "${tableName}" to show by default and exclude`, CANT_VIEW_AND_EXCLUDE: (fieldName: string) => `You cannot select the same field ${fieldName ? fieldName : 'names'} to view and exclude`, CANT_ORDER_AND_EXCLUDE: `You cannot select the same field names to order and exclude`,