{"action":"closed","issue":{"url":"https://api.github.com/repos/doctrine/doctrine2/issues/5753","repository_url":"https://api.github.com/repos/doctrine/doctrine2","labels_url":"https://api.github.com/repos/doctrine/doctrine2/issues/5753/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/doctrine2/issues/5753/comments","events_url":"https://api.github.com/repos/doctrine/doctrine2/issues/5753/events","html_url":"https://github.com/doctrine/doctrine2/issues/5753","id":144933574,"number":5753,"title":"[Question] What is the expected behavior when removing object in a Many-to-Many relationship","user":{"login":"sharky98","id":8150191,"avatar_url":"https://avatars3.githubusercontent.com/u/8150191?v=4","gravatar_id":"","url":"https://api.github.com/users/sharky98","html_url":"https://github.com/sharky98","followers_url":"https://api.github.com/users/sharky98/followers","following_url":"https://api.github.com/users/sharky98/following{/other_user}","gists_url":"https://api.github.com/users/sharky98/gists{/gist_id}","starred_url":"https://api.github.com/users/sharky98/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharky98/subscriptions","organizations_url":"https://api.github.com/users/sharky98/orgs","repos_url":"https://api.github.com/users/sharky98/repos","events_url":"https://api.github.com/users/sharky98/events{/privacy}","received_events_url":"https://api.github.com/users/sharky98/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-03-31T15:25:14Z","updated_at":"2017-09-09T18:34:48Z","closed_at":"2017-09-09T18:34:48Z","author_association":"NONE","body":"Hello everyone, I hope this is the right place to ask questions?\n\nI'm having hard time to understand a behavior of Many-To-Many relationship. It is regarding when we want to RESTRICT the onDelete cascading.\n\nYou can check a gist with all the files I used (https://gist.github.com/sharky98/7cd18973a4a7148a5a5e5d19675e1bf2).\n\nI've discover that behavior in Symfony 2.8.3, Doctrine/Common 2.6.1 and Doctrine/Orm 2.5.4.\nI've been able to replicate in a very simple use case using Symfony 2.8.3 and Doctrine/Common 2.5.3 and Doctrine/Orm 2.4.8.\n\nBasically, I have two entities related to each other with a Many-To-Many relationship. My join table enforce onDelete=\"RESTRICT\".\n\nWhen removing, using the database interface (phpMyAdmin, with MariaDB), the database react as expected, it doesn't allow me to remove a entity that has anything related to it, which is my expected behavior.\n\nWhen removing, using the Entity Manager, the database does not react as expected, it remove first the record in the join table, then remove the object, which does not have any restriction anymore.\n\nI've been trying to look around, but I can only find instruction on the cascading, not the restriction. Is anyone could help me explain the expected behavior, or confirming this is a bug? I feel this could be a bug, since I explicitly stated the RESTRICT on the database level, I feel that the ORM should behave the same way?\n"}}
{"actor":{"display_login":"sharky98"}}