You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's possible to have a column in a table that references a column that is not a primary key in another table, however Directus ignores the column being referenced and always uses the primary key.
To Reproduce
Import the following into a database:
createtabletable_a
(
id uuid not nullprimary key default gen_random_uuid(),
foo uuid unique
);
createtabletable_b
(
id uuid not nullprimary key default gen_random_uuid(),
something uuid not nullreferences table_a (foo)
);
Startup Directus and go to Settings -> Data Model and import Table A.
Import Table B, opening the configuration page for the something field and navigating to the Relationship tab. You'll see that Directus thinks that the Related Collection (table_a) field is id when it should be foo.
Set the Interface -> Many to One -> Display Template value to {{foo}}, and the Display -> Related Values -> Display Template value to {{foo}}.
Insert an entry into Table A.
Attempt to insert an entry into Table B selecting the item from Table A as the value for Something
Click save, and be given the following error:
{
"message": "Invalid foreign key for field \"something\" in collection \"table_b\".",
"extensions": {
"code": "INVALID_FOREIGN_KEY",
"collection": "table_b",
"field": "something"
}
}
Directus Version
v10.9.3
Hosting Strategy
Self-Hosted (Docker Image)
The text was updated successfully, but these errors were encountered:
Describe the Bug
It's possible to have a column in a table that references a column that is not a primary key in another table, however Directus ignores the column being referenced and always uses the primary key.
To Reproduce
Startup Directus and go to Settings -> Data Model and import
Table A
.Import
Table B
, opening the configuration page for thesomething
field and navigating to the Relationship tab. You'll see that Directus thinks that the Related Collection (table_a
) field isid
when it should befoo
.Set the Interface -> Many to One -> Display Template value to
{{foo}}
, and the Display -> Related Values -> Display Template value to{{foo}}
.Insert an entry into
Table A
.Attempt to insert an entry into
Table B
selecting the item fromTable A
as the value forSomething
Click save, and be given the following error:
Directus Version
v10.9.3
Hosting Strategy
Self-Hosted (Docker Image)
The text was updated successfully, but these errors were encountered: