Skip to content

Commit 5b0fd0d

Browse files
committed
fix: MultipleObjectsReturned error in left object in get neighbors
1 parent d1f1679 commit 5b0fd0d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

taiga/base/neighbors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def get_neighbors(obj, results_set=None):
6464
right_object_id = row[3]
6565

6666
try:
67-
left = results_set.get(id=left_object_id)
67+
left = results_set.filter(id=left_object_id).first()
6868
except ObjectDoesNotExist:
6969
left = None
7070

tests/integration/test_neighbors.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ def test_results_set_repeat_id(self):
4848

4949
assert neighbors.right == us1
5050

51+
def test_results_set_left_repeat_id(self):
52+
project = f.ProjectFactory.create()
53+
54+
us1 = f.UserStoryFactory.create(project=project)
55+
f.RolePointsFactory.create(user_story=us1)
56+
f.RolePointsFactory.create(user_story=us1)
57+
58+
us2 = f.UserStoryFactory.create(project=project)
59+
f.RolePointsFactory.create(user_story=us2)
60+
61+
neighbors = n.get_neighbors(us2, results_set=UserStory.objects.get_queryset().filter(role_points__isnull=False))
62+
63+
assert neighbors.left == us1
64+
5165
def test_filtered_by_tags(self):
5266
tag_names = ["test"]
5367
project = f.ProjectFactory.create()

0 commit comments

Comments
 (0)