Merge pull request #3032 from Budibase/fix/data-section-issues
Potential fix for issues with updating and saving rows and columns
This commit is contained in:
commit
fc53e3e8b8
|
@ -5,7 +5,6 @@
|
|||
import RelationshipRenderer from "./RelationshipRenderer.svelte"
|
||||
import AttachmentRenderer from "./AttachmentRenderer.svelte"
|
||||
import ArrayRenderer from "./ArrayRenderer.svelte"
|
||||
import InternalRenderer from "./InternalRenderer.svelte"
|
||||
|
||||
export let row
|
||||
export let schema
|
||||
|
@ -23,9 +22,7 @@
|
|||
number: StringRenderer,
|
||||
longform: StringRenderer,
|
||||
array: ArrayRenderer,
|
||||
internal: InternalRenderer,
|
||||
}
|
||||
|
||||
$: type = schema?.type ?? "string"
|
||||
$: customRenderer = customRenderers?.find(x => x.column === schema?.name)
|
||||
$: renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer
|
||||
|
|
|
@ -16,29 +16,11 @@
|
|||
import { Pagination } from "@budibase/bbui"
|
||||
|
||||
let hideAutocolumns = true
|
||||
let schema
|
||||
$: isUsersTable = $tables.selected?._id === TableNames.USERS
|
||||
$: type = $tables.selected?.type
|
||||
$: isInternal = type !== "external"
|
||||
$: {
|
||||
schema = $tables.selected?.schema
|
||||
$: schema = $tables.selected?.schema
|
||||
|
||||
// Manually add these as we don't want them to be 'real' auto-columns
|
||||
schema._id = {
|
||||
type: "internal",
|
||||
editable: false,
|
||||
displayName: "ID",
|
||||
autocolumn: true,
|
||||
}
|
||||
if (isInternal) {
|
||||
schema._rev = {
|
||||
type: "internal",
|
||||
editable: false,
|
||||
displayName: "Revision",
|
||||
autocolumn: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
$: id = $tables.selected?._id
|
||||
$: search = searchTable(id)
|
||||
$: columnOptions = Object.keys($search.schema || {})
|
||||
|
|
|
@ -91,6 +91,9 @@ exports.save = async function (ctx) {
|
|||
for (let propKey of Object.keys(tableToSave.schema)) {
|
||||
let column = tableToSave.schema[propKey]
|
||||
let oldColumn = oldTable.schema[propKey]
|
||||
if (oldColumn && oldColumn.type === "internal") {
|
||||
oldColumn.type = "auto"
|
||||
}
|
||||
if (oldColumn && oldColumn.type !== column.type) {
|
||||
ctx.throw(400, "Cannot change the type of a column")
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ exports.FieldTypes = {
|
|||
FORMULA: "formula",
|
||||
AUTO: "auto",
|
||||
JSON: "json",
|
||||
INTERNAL: "internal",
|
||||
}
|
||||
|
||||
exports.RelationshipTypes = {
|
||||
|
|
|
@ -200,6 +200,12 @@ exports.inputProcessing = (
|
|||
clonedRow[key] = exports.coerce(value, field.type)
|
||||
}
|
||||
}
|
||||
|
||||
if (!clonedRow._id) {
|
||||
clonedRow._id = row._id
|
||||
clonedRow._rev = row._rev
|
||||
}
|
||||
|
||||
// handle auto columns - this returns an object like {table, row}
|
||||
return processAutoColumn(user, copiedTable, clonedRow, opts)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue