Only throw on creation or primary display edition
This commit is contained in:
parent
59bdae57cc
commit
3a36289306
|
@ -68,17 +68,24 @@ function checkDefaultFields(table: Table) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function guardTable(table: Table) {
|
async function guardTable(table: Table, isCreate: boolean) {
|
||||||
checkDefaultFields(table)
|
checkDefaultFields(table)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
table.primaryDisplay &&
|
table.primaryDisplay &&
|
||||||
!canBeDisplayColumn(table.schema[table.primaryDisplay]?.type)
|
!canBeDisplayColumn(table.schema[table.primaryDisplay]?.type)
|
||||||
) {
|
) {
|
||||||
throw new HTTPError(
|
// Prevent throwing errors from existing badly configured tables. Only throw for new tables or if this setting is being updated
|
||||||
`Column "${table.primaryDisplay}" cannot be used as a display type.`,
|
if (
|
||||||
400
|
isCreate ||
|
||||||
)
|
(await sdk.tables.getTable(table._id!)).primaryDisplay !==
|
||||||
|
table.primaryDisplay
|
||||||
|
) {
|
||||||
|
throw new HTTPError(
|
||||||
|
`Column "${table.primaryDisplay}" cannot be used as a display type.`,
|
||||||
|
400
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +133,7 @@ export async function save(ctx: UserCtx<SaveTableRequest, SaveTableResponse>) {
|
||||||
|
|
||||||
const isCreate = !table._id
|
const isCreate = !table._id
|
||||||
|
|
||||||
guardTable(table)
|
await guardTable(table, isCreate)
|
||||||
|
|
||||||
let savedTable: Table
|
let savedTable: Table
|
||||||
if (isCreate) {
|
if (isCreate) {
|
||||||
|
|
Loading…
Reference in New Issue