Let's assume name and id are the only fields on my user table and I have an unique constraints set for both. So if I have a value with id 2, name "robel", why is the below code giving me validation exception?
User old = UserFindByName("robel")
old.setName("changed")
old.save(failOnError: true)
User neew = new User(name:"robel")
neew.save(failOnError: true)
I tried setting breakpoints and checking if the value of old is changed before saving neew,and i am sure its changed but the last line is giving me an exception saying name:"robel" needs to be unique .Why is this happening?