Skip to content

Commit

Permalink
fix: handle FK-is-PK scenario in c-select
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott18 committed Jan 29, 2025
1 parent e36dba3 commit 658d3a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/coalesce-vue-vuetify2/src/components/input/c-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ export default defineComponent({
return meta;
}
if (meta.role == "referenceNavigation" && "foreignKey" in meta) {
if (meta.foreignKey.role == "primaryKey") {
throw new Error(
"c-select cannot be used for properties whose foreign key is simultaneously a primary key."
);
}
return meta.foreignKey;
}
return null;
Expand Down
5 changes: 5 additions & 0 deletions src/coalesce-vue-vuetify3/src/components/input/c-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,11 @@ const modelKeyProp = computed((): ForeignKeyProperty | null => {
return meta;
}
if (meta.role == "referenceNavigation" && "foreignKey" in meta) {
if (meta.foreignKey.role == "primaryKey") {
throw new Error(
"c-select cannot be used for properties whose foreign key is simultaneously a primary key."
);
}
return meta.foreignKey;
}
return null;
Expand Down

0 comments on commit 658d3a5

Please sign in to comment.