From f2484eafecdccc4a386bf0552826f2c7b7f6b8cf Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Tue, 14 Mar 2023 16:13:14 +0000 Subject: [PATCH] Fix for spaces in table names (external). --- packages/server/src/integrations/utils.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/server/src/integrations/utils.ts b/packages/server/src/integrations/utils.ts index ba80bb9899..de8b318bb1 100644 --- a/packages/server/src/integrations/utils.ts +++ b/packages/server/src/integrations/utils.ts @@ -4,6 +4,7 @@ import { FieldTypes, BuildSchemaErrors, InvalidColumns } from "../constants" const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}` const ROW_ID_REGEX = /^\[.*]$/g +const ENCODED_SPACE = encodeURIComponent(" ") const SQL_NUMBER_TYPE_MAP = { integer: FieldTypes.NUMBER, @@ -79,6 +80,10 @@ export function isExternalTable(tableId: string) { } export function buildExternalTableId(datasourceId: string, tableName: string) { + // encode spaces + if (tableName.includes(" ")) { + tableName = encodeURIComponent(tableName) + } return `${datasourceId}${DOUBLE_SEPARATOR}${tableName}` } @@ -90,6 +95,10 @@ export function breakExternalTableId(tableId: string | undefined) { let datasourceId = parts.shift() // if they need joined let tableName = parts.join(DOUBLE_SEPARATOR) + // if contains encoded spaces, decode it + if (tableName.includes(ENCODED_SPACE)) { + tableName = decodeURIComponent(tableName) + } return { datasourceId, tableName } }