O3-5145: Add uniqueness constraints for billable service fields#43
O3-5145: Add uniqueness constraints for billable service fields#43UjjawalPrabhat wants to merge 2 commits intoopenmrs:mainfrom
Conversation
NethmiRodrigo
left a comment
There was a problem hiding this comment.
This mentions that "Administrators should clean duplicate data before deploying update", but I think we should have a better way of having a migration so that this change wouldn't affect existing implementations, that possible doesn't require administrators having to mess with existing data. Is that possible? @wikumChamith @dkayiwa tagging you for advice
|
@UjjawalPrabhat have you added the constraints in the Hibernate mappings for Billable Services? |
This might be a bit tricky since handling duplicates really depends on the user. Some may prefer to delete them, while others might want to rename them. If the next release is going to be a major one, I think this approach should be fine. |
|
Is this pull request about adding a unique constraint for billable service fields? Or is it adding adding new fetch methods? |
|
@wikumChamith can we move this forward? |
|
We don't generally enforce uniqueness constraints through Hibernate or DB level indices. Usually we have a validator that rejects the ability to create duplicates. I'm not sure why were doing something different here? |
f7ccd63 to
572db17
Compare
@ibacher @dkayiwa I’ve updated my approach based on the discussion. Could you please take a look and let me know if there are any further enhancements or changes you’d recommend? |
Summary
This PR implements server-side validation to ensure the uniqueness of
BillableServicenames and short names. Previously, it was possible to create duplicate services, leading to data integrity issues.Changes
BillableServiceValidatorto reject duplicate names and short names (case-insensitive).BillableService.billableServiceIdfrominttoIntegerto correctly distinguish between new (null ID) and existing (ID 0) services during validation.HibernateBillableServiceDAOandBillableServiceSearchto support filtering byshortNamefor efficient validation.BillableServiceServiceImplTestto verify the new constraints.Related Issue
O3-5145