This commit is contained in:
Adria Navarro 2024-07-26 14:35:36 +02:00
parent afd9ad9d8d
commit 3a095c5071
6 changed files with 12 additions and 12 deletions

View File

@ -1,6 +1,6 @@
import {
CONSTANT_EXTERNAL_ROW_COLS,
CONSTANT_INTERNAL_ROW_COLS,
PROTECTED_INTERNAL_COLUMNS,
} from "@budibase/shared-core"
export function expectFunctionWasCalledTimesWith(
@ -14,7 +14,7 @@ export function expectFunctionWasCalledTimesWith(
}
export const expectAnyInternalColsAttributes: {
[K in (typeof CONSTANT_INTERNAL_ROW_COLS)[number]]: any
[K in (typeof PROTECTED_INTERNAL_COLUMNS)[number]]: any
} = {
tableId: expect.anything(),
type: expect.anything(),

View File

@ -17,7 +17,7 @@
SWITCHABLE_TYPES,
ValidColumnNameRegex,
helpers,
CONSTANT_INTERNAL_ROW_COLS,
PROTECTED_INTERNAL_COLUMNS,
CONSTANT_EXTERNAL_ROW_COLS,
} from "@budibase/shared-core"
import { createEventDispatcher, getContext, onMount } from "svelte"
@ -490,7 +490,7 @@
const newError = {}
const prohibited = externalTable
? CONSTANT_EXTERNAL_ROW_COLS
: CONSTANT_INTERNAL_ROW_COLS
: PROTECTED_INTERNAL_COLUMNS
if (!externalTable && fieldInfo.name?.startsWith("_")) {
newError.name = `Column name cannot start with an underscore.`
} else if (fieldInfo.name && !fieldInfo.name.match(ValidColumnNameRegex)) {

View File

@ -1,5 +1,5 @@
import { context, HTTPError } from "@budibase/backend-core"
import { CONSTANT_INTERNAL_ROW_COLS } from "@budibase/shared-core"
import { PROTECTED_INTERNAL_COLUMNS } from "@budibase/shared-core"
import env from "../../../../environment"
import { fullSearch, paginatedSearch } from "./utils"
import { getRowParams, InternalTables } from "../../../../db/utils"
@ -75,7 +75,7 @@ export async function search(
}
if (options.fields) {
const fields = [...options.fields, ...CONSTANT_INTERNAL_ROW_COLS]
const fields = [...options.fields, ...PROTECTED_INTERNAL_COLUMNS]
response.rows = response.rows.map((r: any) => pick(r, fields))
}

View File

@ -11,7 +11,7 @@ import { features } from "@budibase/pro"
import {
helpers,
CONSTANT_EXTERNAL_ROW_COLS,
CONSTANT_INTERNAL_ROW_COLS,
PROTECTED_INTERNAL_COLUMNS,
} from "@budibase/shared-core"
import { cloneDeep } from "lodash/fp"
@ -149,7 +149,7 @@ export function allowedFields(view: View | ViewV2) {
return fieldSchema.visible && !fieldSchema.readonly
}),
...CONSTANT_EXTERNAL_ROW_COLS,
...CONSTANT_INTERNAL_ROW_COLS,
...PROTECTED_INTERNAL_COLUMNS,
]
}

View File

@ -1,4 +1,4 @@
export const CONSTANT_INTERNAL_ROW_COLS = [
export const PROTECTED_INTERNAL_COLUMNS = [
"_id",
"_rev",
"type",
@ -10,5 +10,5 @@ export const CONSTANT_INTERNAL_ROW_COLS = [
export const CONSTANT_EXTERNAL_ROW_COLS = ["_id", "_rev", "tableId"] as const
export function isInternalColumnName(name: string): boolean {
return (CONSTANT_INTERNAL_ROW_COLS as readonly string[]).includes(name)
return (PROTECTED_INTERNAL_COLUMNS as readonly string[]).includes(name)
}

View File

@ -1,5 +1,5 @@
import { FieldType, Table } from "@budibase/types"
import { CONSTANT_INTERNAL_ROW_COLS } from "./constants"
import { PROTECTED_INTERNAL_COLUMNS } from "./constants"
const allowDisplayColumnByType: Record<FieldType, boolean> = {
[FieldType.STRING]: true,
@ -69,7 +69,7 @@ export function findDuplicateInternalColumns(table: Table): string[] {
}
}
}
for (let internalColumn of CONSTANT_INTERNAL_ROW_COLS) {
for (let internalColumn of PROTECTED_INTERNAL_COLUMNS) {
if (casedKeys.find(key => key === internalColumn)) {
duplicates.push(internalColumn)
}