Database deletions should use delete orphan
Bug #1096549 reported by
Gary Kotton
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
neutron |
Fix Released
|
Medium
|
Senhua Huang |
Bug Description
Following a review on cascade='delete', the following was suggested:
"Typically, cascade is usually left at its default, or configured as all, delete-orphan, indicating the child objects should be treated as “owned” by the parent."
tags: | added: db |
Changed in quantum: | |
importance: | Undecided → Low |
importance: | Low → Medium |
status: | New → Confirmed |
Changed in quantum: | |
assignee: | nobody → Senhua Huang (senhuang) |
Changed in quantum: | |
milestone: | none → havana-1 |
Changed in quantum: | |
status: | Fix Committed → Fix Released |
Changed in neutron: | |
milestone: | havana-1 → 2013.2 |
To post a comment you must log in.
Hi Gary,
Do you mean we should add "delete-orphan" to cascade in the following lines (141-146) of codes in quantum/ db/models_ v2.py: p(DNSNameServer , backref='subnet', cascade='delete') p(Route, backref='subnet', cascade='delete')
dns_nameservers = orm.relationshi
routes = orm.relationshi
and the following lines (68-75) in quantum/ db/security_ groups_ db.py: p(securityGroup , backref= orm.backref( 'rules' , cascade='all, delete'), primaryjoin= "SecurityGroup. id==SecurityGro upRule. security_ group_id" ) p(SecurityGroup , backref= orm.backref( 'source_ rules, cascade= 'all,delete' ), primaryjoin= "SecurityGroup. id==SecurityGro upRule. source_ group_id" )?
security_group = orm.relationshi
source_group = orm.relationshi
According to the online document of SqlAlchemy, "delete-orphan cascade implies that each child object can only have one parent at a time, so is configured in the vast majority of cases on a one-to-many relationship." Is this the case here for the relationship defined by dns_nameservers, routes, security_group, and source_group? Thanks!