(GRAILS-9936) Fixing unique key constraoint validation logic