Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create treeview O2M #7228

Closed
3 tasks done
bahamut657 opened this issue Aug 5, 2021 · 1 comment
Closed
3 tasks done

Cannot create treeview O2M #7228

bahamut657 opened this issue Aug 5, 2021 · 1 comment

Comments

@bahamut657
Copy link

Preflight Checklist

Describe the Bug

It is not possible to configure parent->child where child is on the same collection

To Reproduce

  1. Create collection "topics" composed by id (PK) and name
  2. Add O2M relation with the collection itself, selecting the PK as FK
    => Saving the relation will result in an error (Invalid SQL)

What version of Directus are you using?

9.0.0-rc.88

What version of Node.js are you using?

official dockerhub directus image

What database are you using?

mysql

What browser are you using?

Chrome

What operating system are you using?

Armbian

How are you deploying Directus?

docker

@rijkvanzanten
Copy link
Member

This makes sense!

Add O2M relation with the collection itself, selecting the PK as FK

You can't have it save the foreign key on top of the primary key field, as that would kill the current item (as you would replace the current parent item's ID with the ID of the child). Add a new field to use as the foreign key instead (something like a parent_id field 👍🏻 )

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants