diff --git a/neomodel/cardinality.py b/neomodel/cardinality.py index 2e2fdf0d..099bf578 100644 --- a/neomodel/cardinality.py +++ b/neomodel/cardinality.py @@ -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") diff --git a/neomodel/match.py b/neomodel/match.py index 022307cf..2773d6e5 100644 --- a/neomodel/match.py +++ b/neomodel/match.py @@ -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))