Fix handling of repeated names in SQL store