stockpile-co / api

The API for Stockpile, an app that manages stuff for organizations.
0 stars 1 forks source link

Fix rental date validation #252

Closed AdamVig closed 7 years ago

AdamVig commented 7 years ago

On insert, the validation should check only against other items with the same barcode.

On update, the validation should compare against items with the same barcode but not the current rental.

The trigger code for calling the insert validation procedure:

call validateRentalNoConflict(new.organizationID, new.barcode, new.startDate, new.endDate)
AdamVig commented 7 years ago

Instead of using a single stored procedure called by both the BEFORE INSERT and BEFORE UPDATE hooks, I had to write slightly different triggers for each of them.