Skip to content

Commit

Permalink
Don't use ID as a unique key for any given query
Browse files Browse the repository at this point in the history
Because parent_id with wildcards can match different objects that have
the same ID, this old use of records indexed by IDs to get the union
of a bunch of records no longer works. Instead, rely on the fact that
the same record, matched multiple times, is the same object in
memory, and use its memory location as its unique ID. This is kind of
a hack, but I couldn't think of a better solution.

Although this is one obvious place where we rely on every object in a
given "result set" having a unique ID, there may be others hidden
elsewhere.

Refs: Kinto#1616
  • Loading branch information
glasserc committed May 4, 2018
1 parent 56e428c commit b313111
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kinto/core/storage/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,8 @@ def extract_record_set(records, filters, sorting,
paginated = {}
for rule in pagination_rules:
values = apply_filters(filtered, rule)
paginated.update(((x[id_field], x) for x in values))
paginated = paginated.values()
paginated.update((id(x), x) for x in values)
paginated = list(paginated.values())
else:
paginated = filtered

Expand Down

0 comments on commit b313111

Please sign in to comment.