newdb: Handle duplicate values when setting many-many fields

Fixes an error when merging book records that have the same tags.