Ejemplo n.º 1
0
 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,
     )
Ejemplo n.º 2
0
 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),
     ), )
Ejemplo n.º 3
0
 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,
     ), )
Ejemplo n.º 4
0
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())),
    )
Ejemplo n.º 5
0
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())),
    )
Ejemplo n.º 6
0
def test_expr():
    ast = expr("foo")
    assert_that(
        str(ast),
        is_(equal_to("foo")),
    )
    assert_that(
        dict(ast),
        is_(equal_to(dict())),
    )
Ejemplo n.º 7
0
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())),
    )
Ejemplo n.º 8
0
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())),
    )
Ejemplo n.º 9
0
def test_ret():
    ast = ret(expr(1))
    assert_that(
        str(ast),
        is_(equal_to("RETURN 1")),
    )
    assert_that(
        dict(ast),
        is_(equal_to(dict())),
    )
Ejemplo n.º 10
0
 def set_item(cls, parameter: Parameter) -> SetItem:
     return SetVariableItem(
         target=Variable(parameter.key),
         value=expr(parameter),
     )