Skip to content

Commit

Permalink
[HOTFIX]: Bypass node saving when smart building edges
Browse files Browse the repository at this point in the history
  • Loading branch information
amadolid committed Jul 28, 2023
1 parent 659012d commit 48a5964
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion jaseci_core/jaseci/prim/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def smart_build_fast_edge_ids(self):
edge.jid = v[2] if len(v) > 2 else uuid.uuid4().urn
edge.context = v[3] if len(v) > 3 else {}
edge.save()
self._fast_edge_ids.add_obj(edge)
self._fast_edge_ids.add_obj(edge, bypass=True)

def smart_add_edge(self, obj):
# make sure fast edges built
Expand Down
14 changes: 9 additions & 5 deletions jaseci_core/jaseci/utils/id_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def __init__(self, parent_obj, auto_save=True, in_list=None):
def cache_reset(self):
self.cached_objects = []

def add_obj(self, obj, push_front=False, allow_dups=False, silent=False):
def add_obj(
self, obj, push_front=False, allow_dups=False, silent=False, bypass=False
):
"""Adds a obj obj to Jaseci object"""
self.parent_obj.check_hooks_match(obj)
if not allow_dups and obj.jid in self:
Expand All @@ -39,10 +41,12 @@ def add_obj(self, obj, push_front=False, allow_dups=False, silent=False):
self.insert(0, obj.jid)
else:
self.append(obj.jid)
if not obj.j_parent:
obj.j_parent = self.parent_obj.jid
self.save(obj)
self.save()

if not bypass:
if not obj.j_parent:
obj.j_parent = self.parent_obj.jid
self.save(obj)
self.save()

def add_obj_list(self, obj_list, push_front=False, allow_dups=False, silent=False):
self.cache_reset()
Expand Down

0 comments on commit 48a5964

Please sign in to comment.