Fix for spaces in table names (external).
This commit is contained in:
parent
c2de0ade7d
commit
f2484eafec
|
@ -4,6 +4,7 @@ import { FieldTypes, BuildSchemaErrors, InvalidColumns } from "../constants"
|
||||||
|
|
||||||
const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`
|
const DOUBLE_SEPARATOR = `${SEPARATOR}${SEPARATOR}`
|
||||||
const ROW_ID_REGEX = /^\[.*]$/g
|
const ROW_ID_REGEX = /^\[.*]$/g
|
||||||
|
const ENCODED_SPACE = encodeURIComponent(" ")
|
||||||
|
|
||||||
const SQL_NUMBER_TYPE_MAP = {
|
const SQL_NUMBER_TYPE_MAP = {
|
||||||
integer: FieldTypes.NUMBER,
|
integer: FieldTypes.NUMBER,
|
||||||
|
@ -79,6 +80,10 @@ export function isExternalTable(tableId: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function buildExternalTableId(datasourceId: string, tableName: string) {
|
export function buildExternalTableId(datasourceId: string, tableName: string) {
|
||||||
|
// encode spaces
|
||||||
|
if (tableName.includes(" ")) {
|
||||||
|
tableName = encodeURIComponent(tableName)
|
||||||
|
}
|
||||||
return `${datasourceId}${DOUBLE_SEPARATOR}${tableName}`
|
return `${datasourceId}${DOUBLE_SEPARATOR}${tableName}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +95,10 @@ export function breakExternalTableId(tableId: string | undefined) {
|
||||||
let datasourceId = parts.shift()
|
let datasourceId = parts.shift()
|
||||||
// if they need joined
|
// if they need joined
|
||||||
let tableName = parts.join(DOUBLE_SEPARATOR)
|
let tableName = parts.join(DOUBLE_SEPARATOR)
|
||||||
|
// if contains encoded spaces, decode it
|
||||||
|
if (tableName.includes(ENCODED_SPACE)) {
|
||||||
|
tableName = decodeURIComponent(tableName)
|
||||||
|
}
|
||||||
return { datasourceId, tableName }
|
return { datasourceId, tableName }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue