Merge pull request #13512 from Budibase/budi-8126/fix-changing-column-type
Fix changing column type
This commit is contained in:
commit
c986cf2b56
|
@ -56,8 +56,8 @@
|
|||
let primaryDisplay
|
||||
let indexes = [...($tables.selected.indexes || [])]
|
||||
let isCreating = undefined
|
||||
let relationshipPart1 = PrettyRelationshipDefinitions.Many
|
||||
let relationshipPart2 = PrettyRelationshipDefinitions.One
|
||||
let relationshipPart1 = PrettyRelationshipDefinitions.MANY
|
||||
let relationshipPart2 = PrettyRelationshipDefinitions.ONE
|
||||
let relationshipTableIdPrimary = null
|
||||
let relationshipTableIdSecondary = null
|
||||
let table = $tables.selected
|
||||
|
@ -170,7 +170,7 @@
|
|||
$: typeEnabled =
|
||||
!originalName ||
|
||||
(originalName &&
|
||||
SWITCHABLE_TYPES[editableColumn.type] &&
|
||||
SWITCHABLE_TYPES[field.type] &&
|
||||
!editableColumn?.autocolumn)
|
||||
|
||||
const fieldDefinitions = Object.values(FIELDS).reduce(
|
||||
|
@ -363,9 +363,14 @@
|
|||
|
||||
function getAllowedTypes() {
|
||||
if (originalName) {
|
||||
return (
|
||||
SWITCHABLE_TYPES[editableColumn.type] || [editableColumn.type]
|
||||
).map(f => FIELDS[f.toUpperCase()])
|
||||
const possibleTypes = (
|
||||
SWITCHABLE_TYPES[field.type] || [editableColumn.type]
|
||||
).map(t => t.toLowerCase())
|
||||
return Object.entries(FIELDS)
|
||||
.filter(([fieldType]) =>
|
||||
possibleTypes.includes(fieldType.toLowerCase())
|
||||
)
|
||||
.map(([_, fieldDefinition]) => fieldDefinition)
|
||||
}
|
||||
|
||||
const isUsers =
|
||||
|
|
|
@ -64,7 +64,7 @@ export function createTablesStore() {
|
|||
if (
|
||||
oldField != null &&
|
||||
oldField?.type !== field.type &&
|
||||
SWITCHABLE_TYPES[oldField?.type]
|
||||
!SWITCHABLE_TYPES[oldField?.type]?.includes(field.type)
|
||||
) {
|
||||
updatedTable.schema[key] = oldField
|
||||
}
|
||||
|
|
|
@ -354,7 +354,7 @@ function copyExistingPropsOver(
|
|||
// If the db column type changed to a non-compatible one, we want to re-fetch it
|
||||
if (
|
||||
updatedColumnType !== existingColumnType &&
|
||||
!SWITCHABLE_TYPES[existingColumnType]?.includes(updatedColumnType)
|
||||
!SWITCHABLE_TYPES[updatedColumnType]?.includes(existingColumnType)
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue