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 primaryDisplay
|
||||||
let indexes = [...($tables.selected.indexes || [])]
|
let indexes = [...($tables.selected.indexes || [])]
|
||||||
let isCreating = undefined
|
let isCreating = undefined
|
||||||
let relationshipPart1 = PrettyRelationshipDefinitions.Many
|
let relationshipPart1 = PrettyRelationshipDefinitions.MANY
|
||||||
let relationshipPart2 = PrettyRelationshipDefinitions.One
|
let relationshipPart2 = PrettyRelationshipDefinitions.ONE
|
||||||
let relationshipTableIdPrimary = null
|
let relationshipTableIdPrimary = null
|
||||||
let relationshipTableIdSecondary = null
|
let relationshipTableIdSecondary = null
|
||||||
let table = $tables.selected
|
let table = $tables.selected
|
||||||
|
@ -170,7 +170,7 @@
|
||||||
$: typeEnabled =
|
$: typeEnabled =
|
||||||
!originalName ||
|
!originalName ||
|
||||||
(originalName &&
|
(originalName &&
|
||||||
SWITCHABLE_TYPES[editableColumn.type] &&
|
SWITCHABLE_TYPES[field.type] &&
|
||||||
!editableColumn?.autocolumn)
|
!editableColumn?.autocolumn)
|
||||||
|
|
||||||
const fieldDefinitions = Object.values(FIELDS).reduce(
|
const fieldDefinitions = Object.values(FIELDS).reduce(
|
||||||
|
@ -363,9 +363,14 @@
|
||||||
|
|
||||||
function getAllowedTypes() {
|
function getAllowedTypes() {
|
||||||
if (originalName) {
|
if (originalName) {
|
||||||
return (
|
const possibleTypes = (
|
||||||
SWITCHABLE_TYPES[editableColumn.type] || [editableColumn.type]
|
SWITCHABLE_TYPES[field.type] || [editableColumn.type]
|
||||||
).map(f => FIELDS[f.toUpperCase()])
|
).map(t => t.toLowerCase())
|
||||||
|
return Object.entries(FIELDS)
|
||||||
|
.filter(([fieldType]) =>
|
||||||
|
possibleTypes.includes(fieldType.toLowerCase())
|
||||||
|
)
|
||||||
|
.map(([_, fieldDefinition]) => fieldDefinition)
|
||||||
}
|
}
|
||||||
|
|
||||||
const isUsers =
|
const isUsers =
|
||||||
|
|
|
@ -64,7 +64,7 @@ export function createTablesStore() {
|
||||||
if (
|
if (
|
||||||
oldField != null &&
|
oldField != null &&
|
||||||
oldField?.type !== field.type &&
|
oldField?.type !== field.type &&
|
||||||
SWITCHABLE_TYPES[oldField?.type]
|
!SWITCHABLE_TYPES[oldField?.type]?.includes(field.type)
|
||||||
) {
|
) {
|
||||||
updatedTable.schema[key] = oldField
|
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 the db column type changed to a non-compatible one, we want to re-fetch it
|
||||||
if (
|
if (
|
||||||
updatedColumnType !== existingColumnType &&
|
updatedColumnType !== existingColumnType &&
|
||||||
!SWITCHABLE_TYPES[existingColumnType]?.includes(updatedColumnType)
|
!SWITCHABLE_TYPES[updatedColumnType]?.includes(existingColumnType)
|
||||||
) {
|
) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue