Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2.0-BETA3
-
Component/s: None
-
Security Level: All
-
Labels:None
Description
I have two Entities: Users and Alerts. They are associated with @ManyToMany, the assiciation table should be "user_alert".
Entities:
http://pastebin.com/m7bca724a
Sample code:
http://pastebin.com/m4e530f42
The "remove" command in the sample code deletes the user entry and alert entry, but not the user_alert entry (which was automatically created though). This leaves an orphan entry (or the DBMS will complain because of FK constraints).
INSERT INTO users (name) VALUES (?)
array(1) {
[1]=>
string(3) "Bob"
}
INSERT INTO alert (name) VALUES (?)
array(1) {
[1]=>
string(9) "Testalert"
}
INSERT INTO user_alert (userId, alertId) VALUES (?, ?)
array(2) {
[0]=>
int(1)
[1]=>
int(1)
}
DELETE FROM users WHERE id = ?
array(1) {
[0]=>
int(1)
}
DELETE FROM alert WHERE id = ?
array(1) {
[0]=>
int(1)
}
The user_alert table should be automatically updated (on creation and removal)...
Issue Links
- relates to
-
DDC-677
Allow DQL DELETE statements to work with join table fk constraints
-
Activity
Roman S. Borschel
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Priority | Major [ 3 ] | Critical [ 2 ] |
Roman S. Borschel
made changes -
| Fix Version/s | 2.0-BETA3 [ 10060 ] |
Benjamin Eberlei
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Assignee | Roman S. Borschel [ romanb ] | Benjamin Eberlei [ beberlei ] |
| Resolution | Fixed [ 1 ] |
Benjamin Eberlei
made changes -
Benjamin Eberlei
made changes -
| Workflow | jira [ 10368 ] | jira-feedback [ 14162 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback [ 14162 ] | jira-feedback2 [ 16026 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback2 [ 16026 ] | jira-feedback3 [ 18279 ] |
This list may be incomplete, as errors occurred whilst retrieving source from linked applications:
- Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-130, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
I think in most cases the entry in the association table should be deleted by the FK constraint. However I think that is currently not the default. You can force it by using onDelete="CASCADE" on the @JoinColumn definitions inside the @JoinTable. That should probably be set by default on join columns on an association table.
I'm not sure its worth supporting manual deletion of association table entries through Doctrine as all databases support proper foreign key constraints and this is the most effective way to delete these entries and also enforces the integrity on the database side.
So I'm rather voting for making onDelete="CASCADE" the default for join columns of association tables unless specified otherwise.