Implement removing the last parent of an element using SQL
When the child element only has one parent, calling remove_child
to remove the only parent can involve one UPDATE
query, to remove the parent's path from all the child paths, and optionally one DELETE
query if the parent has multiple paths.
Example with a parent with one grandparent
Example: A.remove_child(B)
hide empty members
hide circle
left to right direction
class X
X --> A
A ..> B
B --> C
Element | Path | Ordering |
---|---|---|
X | [] | 0 |
A | X | 0 |
B |
|
0 |
C |
|
0 |
Example with a parent with multiple grandparents
hide empty members
hide circle
left to right direction
class X
X --> A
Y --> A
Z --> A
A ..> B
B --> C
Element | Path | Ordering |
---|---|---|
X | [] | 0 |
Y | [] | 0 |
Z | [] | 0 |
A | X | 0 |
A | Y | 0 |
A | Z | 0 |
B |
|
0 |
B |
|
0 |
B |
|
0 |
C |
|
0 |
C |
|
0 |
C |
|
0 |
Once we implement this after #1295 (closed), the old Python implementation of Element.remove_child
can be removed and everything is done in raw SQL.