Skip to content
Snippets Groups Projects
Commit 501759d39088 authored by Fabien Amarger's avatar Fabien Amarger
Browse files

fix: Compare node class if subclassof

When the nodes.VariableRefAttributeAccess and nodes.VariableRefMethodCall were added, the
node comparison function were broken since the class instances are not the same.
This is a problem when using the groupby and an attribute access or method call on projection
variable.
For example:
Any X, S.download_url() GROUPBY X,S WHERE X is ImportProcess, X shacl_report S

were a bad rql query since `S.download_url()` is not the same node (not the same class) as `S`.
But actually it is.

This patch allow this syntax
parent 3d8a220a6082
No related branches found
No related tags found
1 merge request!99fix: Compare node class if subclassof
Pipeline #227314 passed with warnings
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
# def is_equivalent(self, other: "BaseNode") -> bool: # def is_equivalent(self, other: "BaseNode") -> bool:
# Any here really means: any children of BaseNode # Any here really means: any children of BaseNode
def is_equivalent(self: Any, other: Any) -> bool: def is_equivalent(self: Any, other: Any) -> bool:
if other.__class__ is not self.__class__: if not issubclass(self.__class__, other.__class__):
return False return False
for i, child in enumerate(self.children): for i, child in enumerate(self.children):
try: try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment