avniproject / avni-server

Backend APIs for Avni
https://avniproject.org
GNU Affero General Public License v3.0
5 stars 25 forks source link

Location CSV Upload to update location properties fails with UniqueConstraint exception #720

Open himeshr opened 2 months ago

himeshr commented 2 months ago

Describe the bug Bug discovered as part of this ticket. When user attempts to perform Location CSV Upload to update location properties, in-case the update location addressLevel's parent's name is not unique for that addressLevelType in the organisation, then the upload of that entry fails with UniqueConstraint exception.

Exception message: org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2; nested exception is javax.persistence.NonUniqueResultException: query did not return a unique result: 2

To Reproduce Steps to reproduce the behavior:

  1. Create/upload Locations such that the last but one addressLevelType from the bottom has 2 different addressLevels with same title but different lineages.
  2. Attempt to update properties for any of the children of the above parent addressLevel using "Create+edit" mode
  3. Upload fails with "NonUniqueResultException" exception

Refer this ticket for error case.

Expected behavior Location CSV Upload to update location properties is successul even when addressLevel's parent's name is not unique for that addressLevelType in the organisation

Additional Information ErrorStackTrace-3897.txt

Developer Checklist Developer fixing the bug should fill this checklist.