Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion shotgun_api3/lib/mockgun/mockgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,10 @@ def _update_row(self, entity_type, row, data, multi_entity_update_modes=None):
update_mode = multi_entity_update_modes.get(field, "set") if multi_entity_update_modes else "set"

if update_mode == "add":
row[field] += [{"type": item["type"], "id": item["id"]} for item in data[field]]
for item in data[field]:
new_item = {"type": item["type"], "id": item["id"]}
if new_item not in row[field]:
row[field].append(new_item)
elif update_mode == "remove":
row[field] = [
item
Expand Down
3 changes: 2 additions & 1 deletion tests/test_mockgun.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ def test_update_add(self):
"""
Ensures that "add" multi_entity_update_mode works.
"""
# _version2 already exists on the playlist and should not be duplicated
self._mockgun.update(
"Playlist", self._add_playlist["id"], {"versions": [self._version3]},
"Playlist", self._add_playlist["id"], {"versions": [self._version2, self._version3]},
multi_entity_update_modes={"versions": "add"}
)

Expand Down