Do not allow non-match type primary foreign keys

This commit is contained in:
Mel O'Hagan 2022-09-21 09:10:31 +01:00
parent f62888d0f8
commit 9cc931acc4
1 changed files with 13 additions and 0 deletions

View File

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