-
Notifications
You must be signed in to change notification settings - Fork 664
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
[Bug]: Relations: Bugs in deleting many-to-many item #1662
Comments
Have you done any modifications to Keyword resource The modal should display two buttons unless configured differently:
Remove relation removes the relation from the junction table while Delete record first removes the relation, then deletes the target record. I've looked at the source code and I don't see why it'd delete all records 🤔 |
Here you go. Haven't touched any delete actions.
|
I tried to reproduce it using the example from the documentation and Screen.Recording.2024-04-22.at.22.37.38.movCould you share what's sent in the request in the browser's Network tab when you click the delete button? |
A couple things:
|
The SQL is missing the where constraint for the related resource for a many-to-many. In other words, this will work with a many-to-one, but not many-to-many. When I click "Remove relation" Postgres logs: 2024-04-22 17:13:09.393 HST [6181] LOG: execute : delete from "public"."track_genres" where "track_id" = $1 However, it should be This is confirmed in
|
@nickgieschen does your junction table have an explicit primary key or a composite key? AdminJS won't work without explicit keys. The The need for an explicit PK is mentioned in |
Yes, the junction tables all have a pkey. However, the primary key is a compose key. I see that it will not work with relations now. I think there is a problem with terminology, since a compose key can be a primary key. Is there a way to override the actions's default behaviour, so I can still use relations with my current schema?
|
this is a composite key, as I wrote above it won't work since AJS doesn't support composite keys |
Contact Details
nickgieschen3636 in the discord channel
What happened?
I am trying to remove one item from a many-to-many relation. However, when I delete just one item, it deletes all related entites. Also, the delete error message has weird wording.
Step 1: Delete one item
Step 2: Confirm (with buggy message)
Step 3: ALL items are deleted
Bug prevalence
Always
AdminJS dependencies version
"adminjs": "^7.7.2",
What browsers do you see the problem on?
Chrome
Relevant log output
Relevant code that's giving you issues
The text was updated successfully, but these errors were encountered: