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
Creating a many-to-many relationship field that utilizes an existing junction collection works successfully, however Directus still creates a new collection/table which is then not used.
The if (!junctionCollection || collectionExists(junctionCollection)) check specifically is where the logic fails, as the collection name being checked is not the one that is actually being used for the junction.
To Reproduce
Insert the following data:
createtableissue_abc
(
id uuid not nullprimary key default gen_random_uuid(),
name textnot null
);
createtableissue_def
(
id uuid not nullprimary key default gen_random_uuid(),
name textnot null
);
createtableissue_abc_issue_def
(
id serialprimary key,
issue_abc_id uuid not nullreferences issue_abc (id) on delete cascade,
issue_def_id uuid not nullreferences issue_def (id) on delete cascade
);
insert into issue_abc (name) values ('ABC');
insert into issue_def (name) values ('DEF');
Import the Issue Abc and Issue Def collections in the Directus UI.
In the Issue Abc collection, create a new field using the advanced creation modal of type Many to Many Relationship as follows :
Schema
Key: thing
Relationship
Related Collection: issue_def
Junction Collection: issue_abc_issue_def (remove the _1 by default at the end)
Relational Triggers: all set to Delete the issue_abc_issue_def item (cascade)
Check your database, and you'll see that a new issue_abc_issue_def_1 table has been created.
Go to the content editor, Issue Abc collection, and edit the item to add a value to the Thing field.
Check your database, and you'll see that the relationship has been created in the issue_abc_issue_def table, as is expected.
Directus Version
v10.9.3
Hosting Strategy
Self-Hosted (Docker Image)
The text was updated successfully, but these errors were encountered:
Describe the Bug
Creating a many-to-many relationship field that utilizes an existing junction collection works successfully, however Directus still creates a new collection/table which is then not used.
I've traced this down to the following area:
directus/app/src/modules/settings/routes/data-model/field-detail/store/alterations/m2m.ts
Line 135 in 79c2701
directus/app/src/modules/settings/routes/data-model/utils/get-junction-collection-name.ts
Lines 3 to 23 in 79c2701
directus/app/src/modules/settings/routes/data-model/field-detail/store/alterations/m2m.ts
Lines 165 to 190 in 79c2701
The
if (!junctionCollection || collectionExists(junctionCollection))
check specifically is where the logic fails, as the collection name being checked is not the one that is actually being used for the junction.To Reproduce
Issue Abc
andIssue Def
collections in the Directus UI.Issue Abc
collection, create a new field using the advanced creation modal of typeMany to Many Relationship
as follows :thing
issue_def
issue_abc_issue_def
(remove the_1
by default at the end)Delete the issue_abc_issue_def item (cascade)
issue_abc_issue_def_1
table has been created.Issue Abc
collection, and edit the item to add a value to theThing
field.issue_abc_issue_def
table, as is expected.Directus Version
v10.9.3
Hosting Strategy
Self-Hosted (Docker Image)
The text was updated successfully, but these errors were encountered: