Fix encodings

This commit is contained in:
Adria Navarro 2024-12-16 16:55:38 +01:00
parent 6f4f114796
commit 15f2aaf950
3 changed files with 7 additions and 9 deletions

View File

@ -70,6 +70,10 @@ export function encodeTableId(tableId: string) {
}
}
export function encodeViewId(viewId: string) {
return encodeURIComponent(viewId)
}
export function breakExternalTableId(tableId: string) {
const parts = tableId.split(DOUBLE_SEPARATOR)
let datasourceId = parts.shift()

View File

@ -66,7 +66,7 @@ export function getSourceId(ctx: Ctx): { tableId: string; viewId?: string } {
if (docIds.isViewId(sourceId)) {
return {
tableId: utils.extractViewInfoFromID(sourceId).tableId,
viewId: sourceId,
viewId: sql.utils.encodeViewId(sourceId),
}
}
return { tableId: sql.utils.encodeTableId(ctx.params.sourceId) }

View File

@ -1,10 +1,4 @@
import {
context,
db as dbCore,
docIds,
utils,
sql,
} from "@budibase/backend-core"
import { context, db as dbCore, docIds, utils } from "@budibase/backend-core"
import {
DatabaseQueryOpts,
Datasource,
@ -334,7 +328,7 @@ export function extractViewInfoFromID(viewId: string) {
const regex = new RegExp(`^(?<tableId>.+)${SEPARATOR}([^${SEPARATOR}]+)$`)
const res = regex.exec(viewId)
return {
tableId: sql.utils.encodeTableId(res!.groups!["tableId"]),
tableId: res!.groups!["tableId"],
}
}