Rename external

This commit is contained in:
Adria Navarro 2024-07-26 14:37:47 +02:00
parent ee74a84339
commit f9bfe51c81
5 changed files with 9 additions and 9 deletions

View File

@ -1,5 +1,5 @@
import { import {
CONSTANT_EXTERNAL_ROW_COLS, PROTECTED_EXTERNAL_COLUMNS,
PROTECTED_INTERNAL_COLUMNS, PROTECTED_INTERNAL_COLUMNS,
} from "@budibase/shared-core" } from "@budibase/shared-core"
@ -25,7 +25,7 @@ export const expectAnyInternalColsAttributes: {
} }
export const expectAnyExternalColsAttributes: { export const expectAnyExternalColsAttributes: {
[K in (typeof CONSTANT_EXTERNAL_ROW_COLS)[number]]: any [K in (typeof PROTECTED_EXTERNAL_COLUMNS)[number]]: any
} = { } = {
tableId: expect.anything(), tableId: expect.anything(),
_id: expect.anything(), _id: expect.anything(),

View File

@ -18,7 +18,7 @@
ValidColumnNameRegex, ValidColumnNameRegex,
helpers, helpers,
PROTECTED_INTERNAL_COLUMNS, PROTECTED_INTERNAL_COLUMNS,
CONSTANT_EXTERNAL_ROW_COLS, PROTECTED_EXTERNAL_COLUMNS,
} from "@budibase/shared-core" } from "@budibase/shared-core"
import { createEventDispatcher, getContext, onMount } from "svelte" import { createEventDispatcher, getContext, onMount } from "svelte"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
@ -489,7 +489,7 @@
} }
const newError = {} const newError = {}
const prohibited = externalTable const prohibited = externalTable
? CONSTANT_EXTERNAL_ROW_COLS ? PROTECTED_EXTERNAL_COLUMNS
: PROTECTED_INTERNAL_COLUMNS : PROTECTED_INTERNAL_COLUMNS
if (!externalTable && fieldInfo.name?.startsWith("_")) { if (!externalTable && fieldInfo.name?.startsWith("_")) {
newError.name = `Column name cannot start with an underscore.` newError.name = `Column name cannot start with an underscore.`

View File

@ -16,7 +16,7 @@ import {
breakExternalTableId, breakExternalTableId,
breakRowIdField, breakRowIdField,
} from "../../../../integrations/utils" } from "../../../../integrations/utils"
import { utils, CONSTANT_EXTERNAL_ROW_COLS } from "@budibase/shared-core" import { utils, PROTECTED_EXTERNAL_COLUMNS } from "@budibase/shared-core"
import { ExportRowsParams, ExportRowsResult } from "./types" import { ExportRowsParams, ExportRowsResult } from "./types"
import { HTTPError } from "@budibase/backend-core" import { HTTPError } from "@budibase/backend-core"
import pick from "lodash/pick" import pick from "lodash/pick"
@ -99,7 +99,7 @@ export async function search(
} }
if (options.fields) { if (options.fields) {
const fields = [...options.fields, ...CONSTANT_EXTERNAL_ROW_COLS] const fields = [...options.fields, ...PROTECTED_EXTERNAL_COLUMNS]
rows = rows.map((r: any) => pick(r, fields)) rows = rows.map((r: any) => pick(r, fields))
} }

View File

@ -10,7 +10,7 @@ import { HTTPError } from "@budibase/backend-core"
import { features } from "@budibase/pro" import { features } from "@budibase/pro"
import { import {
helpers, helpers,
CONSTANT_EXTERNAL_ROW_COLS, PROTECTED_EXTERNAL_COLUMNS,
PROTECTED_INTERNAL_COLUMNS, PROTECTED_INTERNAL_COLUMNS,
} from "@budibase/shared-core" } from "@budibase/shared-core"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
@ -148,7 +148,7 @@ export function allowedFields(view: View | ViewV2) {
const fieldSchema = view.schema![key] const fieldSchema = view.schema![key]
return fieldSchema.visible && !fieldSchema.readonly return fieldSchema.visible && !fieldSchema.readonly
}), }),
...CONSTANT_EXTERNAL_ROW_COLS, ...PROTECTED_EXTERNAL_COLUMNS,
...PROTECTED_INTERNAL_COLUMNS, ...PROTECTED_INTERNAL_COLUMNS,
] ]
} }

View File

@ -7,7 +7,7 @@ export const PROTECTED_INTERNAL_COLUMNS = [
"tableId", "tableId",
] as const ] as const
export const CONSTANT_EXTERNAL_ROW_COLS = ["_id", "_rev", "tableId"] as const export const PROTECTED_EXTERNAL_COLUMNS = ["_id", "_rev", "tableId"] as const
export function isInternalColumnName(name: string): boolean { export function isInternalColumnName(name: string): boolean {
return (PROTECTED_INTERNAL_COLUMNS as readonly string[]).includes(name) return (PROTECTED_INTERNAL_COLUMNS as readonly string[]).includes(name)