diff --git a/pydal/objects.py b/pydal/objects.py index a27bb0ad4..e29559ba4 100644 --- a/pydal/objects.py +++ b/pydal/objects.py @@ -3000,7 +3000,7 @@ def as_trees(self, parent_name="parent_id", children_name="children", render=Fal row[children_name] = [] for row in rows: parent = row[parent_name] - if parent is None: + if parent not in drows: roots.append(row) else: drows[parent][children_name].append(row)