1
0
Fork 0
mirror of synced 2024-06-14 08:24:48 +12:00

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 4d3f234807
commit 4d73903019
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")
}
}
}