Skip to content

Commit

Permalink
Fix for key collision
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Lubimow committed Oct 9, 2017
1 parent f1f657d commit 30553f7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion rest_framework/schemas/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,17 @@ def __init__(self):
self.methods_counter = Counter()
super(LinkNode, self).__init__()

def get_next_key(self, method):
def _generate_next_key(self, method):
current_val = self.methods_counter[method]
self.methods_counter[method] += 1
return '{}_{}'.format(method, current_val)

def get_next_key(self, method):
while True:
key = self._generate_next_key(method)
if key not in self:
return key


def insert_into(target, keys, value):
"""
Expand Down

0 comments on commit 30553f7

Please sign in to comment.