Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV-3190: Add aliasing to allow multiple joins to same table #243

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

mpsolano
Copy link
Member

No description provided.

@@ -212,8 +212,122 @@ def path(self, *paths):
assert (
not self.entity().is_abstract_base()
), "Please narrow your search by specifying a node subclass"
# TODO: This is the original
for e in entities:
self = self.join(*getattr(self.entity(), e).attr)
Copy link
Contributor

@kulgan kulgan Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not obvious but its creating two join statements, one for the edge and the other for the destination node. Not clear if both joins will need an alias, but pretty sure the destination node needs one.
I played with this a little bit and was able to get the existing tests to pass

this = self
for e in entities:
  relation = getattr(self.entity(), e)
  alias = aliased(Node.get_subclass_named(relation.target_class.__dst_class__))
  this = self.join(relation.attr[0], relation.attr[1].of_type(alias))

I also had to make an update to self.entity() to cater for when the join_point is an AliasedClass not an entity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants