Skip to content

Commit

Permalink
Fix unsaved node checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Marius Conjeaud committed Oct 31, 2023
1 parent 685b270 commit ca5498e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion neomodel/cardinality.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def connect(self, node, properties=None):
:param properties: relationship properties
:return: True / rel instance
"""
if not hasattr(self.source, "element_id"):
if not hasattr(self.source, "element_id") or self.source.element_id is None:
raise ValueError("Node has not been saved cannot connect!")
if len(self):
raise AttemptedCardinalityViolation("Node already has one relationship")
Expand Down
2 changes: 1 addition & 1 deletion neomodel/match.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ def __nonzero__(self):

def __contains__(self, obj):
if isinstance(obj, StructuredNode):
if hasattr(obj, "element_id"):
if hasattr(obj, "element_id") and obj.element_id is not None:
return self.query_cls(self).build_ast()._contains(obj.element_id)
raise ValueError("Unsaved node: " + repr(obj))

Expand Down

0 comments on commit ca5498e

Please sign in to comment.