Skip to content

Commit

Permalink
Merge pull request #94 from evo-company/use-consistent-hash-for-field…
Browse files Browse the repository at this point in the history
…-options

Use consistent hash for field options
  • Loading branch information
kindermax committed Apr 12, 2023
2 parents 9e2cdd7 + f0f2d02 commit 51fcb6f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hiku/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
.. _om.next: https://github.com/omcljs/om/wiki/Documentation-(om.next)
"""
import typing as t
import hashlib

from itertools import chain
from collections import (
Expand All @@ -63,10 +64,13 @@ def _compute_hash(obj: t.Any) -> int:
if isinstance(obj, dict):
return hash(tuple((_compute_hash(k), _compute_hash(v))
for k, v in sorted(obj.items())))
elif isinstance(obj, list):
if isinstance(obj, list):
return hash(tuple(_compute_hash(i) for i in obj))
else:
return hash(obj)
if isinstance(obj, bytes):
return int(hashlib.sha1(obj).hexdigest(), 16)
if isinstance(obj, str):
return int(hashlib.sha1(obj.encode('utf-8')).hexdigest(), 16)
return hash(obj)


class Base:
Expand Down

0 comments on commit 51fcb6f

Please sign in to comment.