aboutsummaryrefslogtreecommitdiffstats
path: root/bsfs
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-02-08 19:54:24 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-02-08 19:54:24 +0100
commitc8fdaaa676afbdcf33344d72bd92b3ccb981cbf8 (patch)
tree3e0b66f5cfd1e16942aff0313de4c744b56bda20 /bsfs
parent1365e21ab9f13597d7fdb4feb0825453f32cae4b (diff)
downloadbsfs-c8fdaaa676afbdcf33344d72bd92b3ccb981cbf8.tar.gz
bsfs-c8fdaaa676afbdcf33344d72bd92b3ccb981cbf8.tar.bz2
bsfs-c8fdaaa676afbdcf33344d72bd92b3ccb981cbf8.zip
ast fixes
Diffstat (limited to 'bsfs')
-rw-r--r--bsfs/query/ast/fetch.py3
-rw-r--r--bsfs/query/ast/filter_.py4
2 files changed, 3 insertions, 4 deletions
diff --git a/bsfs/query/ast/fetch.py b/bsfs/query/ast/fetch.py
index 5e603a1..d653a8a 100644
--- a/bsfs/query/ast/fetch.py
+++ b/bsfs/query/ast/fetch.py
@@ -69,8 +69,7 @@ class All(FetchExpression):
return f'{typename(self)}({self.expr})'
def __hash__(self) -> int:
- # FIXME: Produces different hashes for different orders of self.expr
- return hash((super().__hash__(), tuple(self.expr)))
+ return hash((super().__hash__(), tuple(sorted(self.expr, key=repr))))
def __eq__(self, other: typing.Any) -> bool:
return super().__eq__(other) and self.expr == other.expr
diff --git a/bsfs/query/ast/filter_.py b/bsfs/query/ast/filter_.py
index 81b0de2..798d37f 100644
--- a/bsfs/query/ast/filter_.py
+++ b/bsfs/query/ast/filter_.py
@@ -173,7 +173,7 @@ class _Agg(FilterExpression, abc.Collection):
return f'{typename(self)}({self.expr})'
def __hash__(self) -> int:
- return hash((super().__hash__(), tuple(self.expr))) # FIXME: Unique hash of different orders over self.expr
+ return hash((super().__hash__(), tuple(sorted(self.expr, key=repr))))
def __eq__(self, other) -> bool:
return super().__eq__(other) and self.expr == other.expr
@@ -450,7 +450,7 @@ class OneOf(PredicateExpression, abc.Collection):
return f'{typename(self)}({self.expr})'
def __hash__(self) -> int:
- return hash((super().__hash__(), tuple(self.expr))) # FIXME: Unique hash of different orders over self.expr
+ return hash((super().__hash__(), tuple(sorted(self.expr, key=repr))))
def __eq__(self, other) -> bool:
return super().__eq__(other) and self.expr == other.expr