Merge pull request #7864 from Budibase/bug/sev4/relationship-column-types-must-match

Do not allow non-matching types for primary/foreign keys - External DB
This commit is contained in:
Martin McKeaveney 2022-09-25 13:42:55 +01:00 committed by GitHub
commit 5d68be1c63
1 changed files with 10 additions and 0 deletions

View File

@ -90,6 +90,16 @@
if (inSchema(toTable, toRelate.name, originalToName)) {
errObj.toCol = colError
}
let fromType, toType
if (fromPrimary && fromRelate.fieldName) {
fromType = fromTable?.schema[fromPrimary]?.type
toType = toTable?.schema[fromRelate.fieldName]?.type
}
if (fromType && toType && fromType !== toType) {
errObj.foreign =
"Column type of the foreign key must match the primary key"
}
errors = errObj
}