Closed tbar0970 closed 1 year ago
Do you want to make use of MySQL's ON DUPLICATE KEY UPDATE feature at the database level so that it doesn't throw an exception when this happens? http://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html This wouldn't preclude adding some code on the client side to warn the user and possibly prevent the user from saving the form.
A silent overwrite isn't the behaviour we want, so ON DUPLICATE KEY UPDATE isn't the solution we need.
To catch it server side, we could override db_object::readyToCreate() in the service class, and add a query that checks for existing services for that congregation and date. BUT that would necessitate an extra query for each service saved (sometimes there are a lot saved at once). So given that the existing behaviour is blocking the save correctly (albeit noisily) I think just adding a client-side check would be the best solution right now.
Steps to reproduce:
Expected behaviour: Before form submission, Jethro checks for duplicate dates and blocks submission. (Coudl also add better server-side detection, but client-side detection will make sure all the rest of the data in the form is not lost).