Accounts_contacts Relation has duplicate rows

I have a relation between an contact and an Account. It’s many contacts to one account, but i guess this not the problem. Every time i change something in an contact, lets say the name spelling was wrong, suitecrm creates a new line in the relationship table. The ‘old’ one is not marked as deleted. As result, the listview makes a join to the accounts and get duplicate rows.
Any suggestion how to change this behavior, or is the only way to use a hook and mark old ones as deleted.

Thanks for your help.

It is strange. It should just update your present record instead of inserting a new one.

I have found the error, causing this behavior. I made a Hook doing something with cusom fields for contacts. And in this function i made the insert by my self. So it’s my own error.

Are you delete duplicate record from the DB? :thinking:

I push new contacts via rest into the system. And with in this data is also a know link to the account. Then i have build an hook that creates the row in the accounts_contacts table. In this hook i did not test of an existing link. Now i create the link only if it s not existing.
And yes, the rows that are only exiting because of my error have i deletet now.
Bad idea?

Now, it is not bad idea :bulb: I was just curious to know. Thank you!