def delete(cls, expression: str, *expressions: str, detach: bool = False) -> Delete: return Delete( items=NonEmptySequence[Expression]( expr(expression), *(expr(item) for item in expressions), ), detach=detach, )
def order(cls, item: str, *items: str, order: Optional[SortOrder] = None) -> Order: return Order(items=NonEmptySequence[SortItem]( SortItem( expression=expr(item), order=order, ), *(SortItem( expression=expr(item_), order=order, ) for item_ in items), ), )
def ret(cls, item: ReturnItem, *items: ReturnItem, order: Optional[Order] = None, skip: Optional[int] = None, limit: Optional[int] = None) -> Return: return Return(body=ReturnBody( items=NonEmptySequence[ReturnItem]( item, *(arg for arg in items), ), order=order, skip=Skip(expr(skip)) if skip is not None else None, limit=Limit(expr(limit)) if limit is not None else None, ), )
def test_count(): ast = func.count(expr("foo")) assert_that( str(ast), is_(equal_to("count(foo)")), ) assert_that( dict(ast), is_(equal_to(dict())), )
def test_expr_alias(): ast = expr("foo").as_("bar") assert_that( str(ast), is_(equal_to("foo AS bar")), ) assert_that( dict(ast), is_(equal_to(dict())), )
def test_expr(): ast = expr("foo") assert_that( str(ast), is_(equal_to("foo")), ) assert_that( dict(ast), is_(equal_to(dict())), )
def test_unwind_create(): ast = unwind(expr("foo"), var("bar")).create(node()) assert_that( str(ast), is_(equal_to("UNWIND foo AS bar CREATE ()")), ) assert_that( dict(ast), is_(equal_to(dict())), )
def test_unwind(): ast = unwind(expr("foo"), var("bar")).ret("bar") assert_that( str(ast), is_(equal_to("UNWIND foo AS bar RETURN bar")), ) assert_that( dict(ast), is_(equal_to(dict())), )
def test_ret(): ast = ret(expr(1)) assert_that( str(ast), is_(equal_to("RETURN 1")), ) assert_that( dict(ast), is_(equal_to(dict())), )
def set_item(cls, parameter: Parameter) -> SetItem: return SetVariableItem( target=Variable(parameter.key), value=expr(parameter), )