1
0
Fork 0
mirror of synced 2024-09-28 07:11:40 +12:00

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

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
}