def create_unique(self, entity): entity = Graph.cast(entity) index = len(self.entities) name = _(index) if isinstance(entity, Path): self.names.append(self.create_unique_path(entity, name)) else: raise TypeError("Cannot create unique entity of type %s" % type(entity).__name__) self.entities.append(entity)
def delete(self, entity): entity = Graph.cast(entity) index = len(self.entities) name = _(index) if isinstance(entity, Node): self.delete_node(entity, name) elif isinstance(entity, Relationship): self.delete_relationship(entity, name) elif isinstance(entity, Path): self.delete_path(entity, name) self.entities.append(entity)
def delete(self, entity): """ Append an entity to the DELETE clause of this statement. :arg entity: The entity to delete. """ entity = Graph.cast(entity) index = len(self.entities) name = _(index) if isinstance(entity, Node): self._delete_node(entity, name) elif isinstance(entity, Relationship): self._delete_relationship(entity, name) elif isinstance(entity, Path): self._delete_path(entity, name) self.entities.append(entity)
def create(self, entity): """ Append an entity to the CREATE clause of this statement. :arg entity: The entity to create. """ entity = Graph.cast(entity) index = len(self.entities) name = _(index) if isinstance(entity, Node): self.names.append(self._create_node(entity, name)) elif isinstance(entity, Path): self.names.append(self._create_path(entity, name, unique=False)) else: raise TypeError("Cannot create entity of type %s" % type(entity).__name__) self.entities.append(entity)
def create_unique(self, entity): """ Append an entity to the CREATE UNIQUE clause of this statement. :arg entity: The entity to add. """ entity = Graph.cast(entity) index = len(self.entities) name = _(index) if isinstance(entity, Path): if len(entity) == 0: raise ValueError("Cannot create unique path with zero length") if not any(node.bound or node in self for node in entity.nodes): raise ValueError("At least one node must be bound to create a unique path") self.names.append(self._create_path(entity, name, unique=True)) else: raise TypeError("Cannot create unique entity of type %s" % type(entity).__name__) self.entities.append(entity)
def create_unique(self, entity): """ Append an entity to the CREATE UNIQUE clause of this statement. :arg entity: The entity to add. """ entity = Graph.cast(entity) index = len(self.entities) name = _(index) if isinstance(entity, Path): if len(entity) == 0: raise ValueError("Cannot create unique path with zero length") if not any(node.bound or node in self for node in entity.nodes): raise ValueError( "At least one node must be bound to create a unique path") self.names.append(self._create_path(entity, name, unique=True)) else: raise TypeError("Cannot create unique entity of type %s" % type(entity).__name__) self.entities.append(entity)