def __init__(self, entity, parent=None, params=None, *args, **kwargs): if isinstance(entity, Entity): VM.set_query_var(entity) params = Params(prefix='', key=entity.query_variable) self.__entity__ = entity super(Builder, self).__init__(parent=parent, params=params, *args, **kwargs) if isinstance(entity, Relationship): self.MATCH.node(self.start).rel(entity.query_variable, labels=entity.labels) self.node(self.end) elif isinstance(entity, Node): self.MATCH.node(entity.query_variable, labels=entity.labels) else: msg = ('The entity {} must be either a Node or ' 'Relationship').format(repr(entity)) raise QueryBuilderException(msg) if entity.id is not None: self.WHERE(__.id(self.entity) == entity.id)
def test_can_reuse_params_object_across_pypher_isntances(self): params = Params('xxx') p = Pypher(params=params) p2 = Pypher(params=params) self.assertEqual(id(p.params), id(p2.params))
def __init__(self, connection=None): self.connection = connection self.params = Params(self.PARAM_PREFIX) self.params = None self.units = []