diff options
| author | aspalding <aspalding@procuredhealth.com> | 2018-10-16 10:01:31 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-10-17 11:17:23 -0400 |
| commit | 834c4ec8e4cfc43acf0525e0a4d8c914534f6afd (patch) | |
| tree | eaa94ec0b3a2db6d1a251e4f5338f5b4a2b153f2 /django | |
| parent | 6752c2756eb9be28a37021d664b805ec169369d6 (diff) | |
Moved make_hashable() to django.utils and added tests.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/expressions.py | 11 | ||||
| -rw-r--r-- | django/utils/hashable.py | 9 |
2 files changed, 10 insertions, 10 deletions
diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py index 2bf6316c2e..b21a3b7526 100644 --- a/django/db/models/expressions.py +++ b/django/db/models/expressions.py @@ -9,6 +9,7 @@ from django.db.models import fields from django.db.models.query_utils import Q from django.utils.deconstruct import deconstructible from django.utils.functional import cached_property +from django.utils.hashable import make_hashable class SQLiteNumericMixin: @@ -138,16 +139,6 @@ class Combinable: ) -def make_hashable(value): - if isinstance(value, list): - return tuple(map(make_hashable, value)) - if isinstance(value, dict): - return tuple([ - (key, make_hashable(nested_value)) for key, nested_value in value.items() - ]) - return value - - @deconstructible class BaseExpression: """Base class for all query expressions.""" diff --git a/django/utils/hashable.py b/django/utils/hashable.py new file mode 100644 index 0000000000..859ea8073e --- /dev/null +++ b/django/utils/hashable.py @@ -0,0 +1,9 @@ +def make_hashable(value): + if isinstance(value, list): + return tuple(map(make_hashable, value)) + if isinstance(value, dict): + return tuple([ + (key, make_hashable(nested_value)) + for key, nested_value in value.items() + ]) + return value |
