Skip to content

Commit 13f58d4

Browse files
Added method to check if a path exists from one node to another
1 parent 47250c7 commit 13f58d4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

django_postgresql_dag/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ def path_raw(self, ending_node, directional=True, max_depth=20, **kwargs):
210210

211211
return path
212212

213+
def path_exists(self, ending_node, **kwargs):
214+
try:
215+
return len(list(self.path_raw(ending_node, **kwargs))) >= 1
216+
except NodeNotReachableException:
217+
return False
218+
213219
def path(self, ending_node, **kwargs):
214220
pks = [item.pk for item in self.path_raw(ending_node, **kwargs)]
215221
return self.ordered_queryset_from_pks(pks)

0 commit comments

Comments
 (0)