1
0
Fork 0
mirror of synced 2024-07-30 02:26:11 +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 7c412aaa08
commit f11e56547f

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
}