Skip to content

Commit

Permalink
Merge pull request #168 from seralot/seralot/20240712/fix-multiple-ob…
Browse files Browse the repository at this point in the history
…jects

fix: MultipleObjectsReturned error in get neighbors
  • Loading branch information
CarlosLVar authored Jul 12, 2024
2 parents 2230a17 + e5fb6c7 commit d1f1679
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion taiga/base/neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_neighbors(obj, results_set=None):
left = None

try:
right = results_set.get(id=right_object_id)
right = results_set.filter(id=right_object_id).first()
except ObjectDoesNotExist:
right = None

Expand Down
11 changes: 11 additions & 0 deletions tests/integration/test_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ def test_no_filters(self):
assert neighbors.left == us1
assert neighbors.right == us3

def test_results_set_repeat_id(self):
project = f.ProjectFactory.create()

us1 = f.UserStoryFactory.create(project=project)
f.RolePointsFactory.create(user_story=us1)
f.RolePointsFactory.create(user_story=us1)

neighbors = n.get_neighbors(us1, results_set=UserStory.objects.get_queryset().filter(role_points__isnull=False))

assert neighbors.right == us1

def test_filtered_by_tags(self):
tag_names = ["test"]
project = f.ProjectFactory.create()
Expand Down

0 comments on commit d1f1679

Please sign in to comment.