diff options
| author | Simon Charette <charette.s@gmail.com> | 2020-10-25 17:41:06 -0400 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-10-28 07:21:53 +0100 |
| commit | bbf141bcdc31f1324048af9233583a523ac54c94 (patch) | |
| tree | 0babf338ba1a5d8c5f5710a777eea60dd3b9aa3d /django/db/models/sql/query.py | |
| parent | 556fa4bbba5ba86bc1646a86fb11ab55405d4aa4 (diff) | |
Refs #27149 -- Fixed sql.Query identity.
By making Query subclass BaseExpression in
35431298226165986ad07e91f9d3aca721ff38ec the former defined it's
identity based off _construct_args which is not appropriate.
Diffstat (limited to 'django/db/models/sql/query.py')
| -rw-r--r-- | django/db/models/sql/query.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index ee98984826..8d76b436ee 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -39,6 +39,7 @@ from django.db.models.sql.where import ( ) from django.utils.deprecation import RemovedInDjango40Warning from django.utils.functional import cached_property +from django.utils.hashable import make_hashable from django.utils.tree import Node __all__ = ['Query', 'RawQuery'] @@ -246,6 +247,14 @@ class Query(BaseExpression): for alias in self.alias_map: return alias + @property + def identity(self): + identity = ( + (arg, make_hashable(value)) + for arg, value in self.__dict__.items() + ) + return (self.__class__, *identity) + def __str__(self): """ Return the query as a string of SQL with the parameter values |
