Don't allow foreign key to be the primary key of a row (this would break things).
This commit is contained in:
parent
568128479f
commit
b7a5476135
|
@ -62,6 +62,7 @@
|
||||||
if ($touched.toCol && !toRelate.name) {
|
if ($touched.toCol && !toRelate.name) {
|
||||||
errors.toCol = colNotSet
|
errors.toCol = colNotSet
|
||||||
}
|
}
|
||||||
|
// currently don't support relationships back onto the table itself, needs to relate out
|
||||||
const tableError = "From/to/through tables must be different"
|
const tableError = "From/to/through tables must be different"
|
||||||
if (fromTable && (fromTable === toTable || fromTable === throughTable)) {
|
if (fromTable && (fromTable === toTable || fromTable === throughTable)) {
|
||||||
errors.from = tableError
|
errors.from = tableError
|
||||||
|
@ -241,10 +242,10 @@
|
||||||
bind:error={errors.through}
|
bind:error={errors.through}
|
||||||
bind:value={fromRelationship.through}
|
bind:value={fromRelationship.through}
|
||||||
/>
|
/>
|
||||||
{:else if toTable}
|
{:else if fromRelationship?.relationshipType && toTable}
|
||||||
<Select
|
<Select
|
||||||
label={`Foreign Key (${toTable?.name})`}
|
label={`Foreign Key (${toTable?.name})`}
|
||||||
options={Object.keys(toTable?.schema)}
|
options={Object.keys(toTable?.schema).filter(field => toTable?.primary.indexOf(field) === -1)}
|
||||||
on:change={() => ($touched.foreign = true)}
|
on:change={() => ($touched.foreign = true)}
|
||||||
bind:error={errors.foreign}
|
bind:error={errors.foreign}
|
||||||
bind:value={fromRelationship.fieldName}
|
bind:value={fromRelationship.fieldName}
|
||||||
|
|
Loading…
Reference in New Issue