Quote:
Originally Posted by kovidgoyal
Thinking about it a little, why is the trigger a problem. Surely if the title is changed, the sort value also needs to be changed?
|
I can work around the trigger, but it takes knowledge of how the DB does its writes. Also, because it is a books update trigger, it is invoked whenever any field is written, even if the title hasn't changed.
I am not up enough on triggers to know if one can easily check the old and new values of title and not do the update of title_sort if the title hasn't changed.
Then, even if the trigger is changed, one would need to be careful with transaction order. For example, assume that I can change title_sort in edit metadata. Assume further that I change the title and the title sort. I want my title sort to win, so I would need to ensure that the write of the title happened before the write of title sort, so that the trigger doesn't overwrite my change.
I think it would probably be easier to add a parameter to set_title, specifying the title_sort to use. If it is None, then generate a new one. If not, then use it. However, I haven't thought a lot about it up to now.