Fixed issue in assign duplicates

This issue occurs some times e.g. in Composer, a database exception is thrown without this. I've also seen this on other occasions, it's related to adding a new page.