Enhancement
Improve triggers
Issue description
There is some subtle issues with triggers which need to be improved to bring more clarity into the system.
Developer comments
What is the meaning of insert/update/delete?
Currently it is strictly based on the identity of the statement. Is the statement inserted or updated? Only an existing statement can be updated. New statements (without system id) are inserted. But this makes it tricky, since Topincs uses a delete/insert combo when setting in the API or in the form, when a user uses the bin and enters a new value.
Simple truths:
* After the insert there is more than before the insert.
* After the delete there is less than before the delete.
Given a maximum cardinality of 1, everything is pretty straight forward. An insert happens if the statement count increases from 0 to 1. A delete happens if the statement count decreases from 1 to 0. Any other change is an update: the modification leaves the statement count untouched, but the value or player changes.
If the maximum cardinality is unlimted it gets trickier, but none of the systems in production uses a trigger then.
The rule that is implemented as of now seems to be a good solution. Given a topic T1 and a statement type ST1.
* Only delete on (T1, ST1), fire DELETE triggers.
* Only insert on (T1, ST1), fire INSERT triggers.
* Otherwise, fire UPDATE triggers.
|
Work sessions3
Start |
2023-01-18T10:13:46
|
End |
2023-01-18T12:08:06
|
Participant |
Robert Cerny
|
Start |
2023-01-18T13:04:14
|
End |
2023-01-18T15:31:52
|
Participant |
Robert Cerny
|
Start |
2023-01-19T07:30:00
|
End |
2023-01-19T10:32:40
|
Participant |
Robert Cerny
|
|
We are sorry
This page cannot be displayed in your browser. Use Firefox, Opera, Safari, or Chrome instead.