Remove unnecessary db call when replacing.

When replacing a has_many association with the same one, there is no
need to do a round-trip to the db to create/and drop a new transaction.

[fixes #14220]

review @carlosantoniodasilva

(let me know if I should add a CHANGELOG)