Skip to content

Commit 89d0f0c

Browse files
author
Pablo Chinea
committed
Handles multiple collisions with the same key.
1 parent 2c26774 commit 89d0f0c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

graphene_django/converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def get_choices(choices):
3434
yield choice
3535
else:
3636
name = convert_choice_name(value)
37-
if name in converted_names:
37+
while name in converted_names:
3838
name += '_' + str(len(converted_names))
3939
converted_names.append(name)
4040
description = help_text

graphene_django/tests/test_converter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class Meta:
178178

179179
def test_field_with_choices_collision():
180180
field = models.CharField(help_text='Timezone', choices=(
181+
('Etc/GMT+1+2', 'Fake choice to produce double collision'),
181182
('Etc/GMT+1', 'Greenwich Mean Time +1'),
182183
('Etc/GMT-1', 'Greenwich Mean Time -1'),
183184
))

0 commit comments

Comments
 (0)