Fixing a few issues that became obvious when I was looking at examples of what gets sent to the API for table saving.

This commit is contained in:
mike12345567 2021-11-26 14:14:53 +00:00
parent 4697b21ef1
commit 5e9f3969c9
3 changed files with 4 additions and 5 deletions

View File

@ -102,6 +102,9 @@
if (field.type === AUTO_TYPE) {
field = buildAutoColumn($tables.draft.name, field.name, field.subtype)
}
if (field.type !== LINK_TYPE) {
delete field.fieldName
}
try {
await tables.saveField({
originalName,

View File

@ -122,7 +122,7 @@ export function createTablesStore() {
update(state => {
// delete the original if renaming
// need to handle if the column had no name, empty string
if (originalName || originalName === "") {
if (originalName != null && originalName !== field.name) {
delete state.draft.schema[originalName]
state.draft._rename = {
old: originalName,

View File

@ -44,14 +44,10 @@ exports.save = async function (ctx) {
// the column if you want to change the type
if (oldTable && oldTable.schema) {
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")
}
}
}