def go(col_expr, whereclause, x):
            stmt = lambdas.lambda_stmt(lambda: select(col_expr))
            stmt = stmt.add_criteria(
                lambda stmt: stmt.where(whereclause).order_by(c2 > x),
            )

            return stmt
        def go(col_expr, whereclause, x, y):
            stmt = lambdas.lambda_stmt(lambda: select(col_expr))
            stmt += lambda stmt: stmt.where(whereclause).where(
                and_(c1 == x, c1 < y)
            )

            return stmt
Exemple #3
0
 def go(col_expr, whereclause, p):
     stmt = lambdas.lambda_stmt(lambda: select(col_expr))
     stmt = stmt.add_criteria(lambda stmt: stmt.where(whereclause))
     stmt = stmt.add_criteria(lambda stmt: stmt.order_by(col_expr),
                              track_on=(col_expr, ))
     stmt = stmt.add_criteria(lambda stmt: stmt.where(col_expr == p))
     return stmt
        def go(col_expr, whereclause):
            stmt = lambdas.lambda_stmt(lambda: select(col_expr))
            stmt = stmt.add_criteria(
                lambda stmt: stmt.where(whereclause), enable_tracking=False
            )

            return stmt
Exemple #5
0
        def go(col_expr, whereclause, p):
            stmt = lambdas.lambda_stmt(lambda: select(col_expr))
            stmt = stmt.add_criteria(
                lambda stmt: stmt.where(whereclause).order_by(col_expr > p),
                track_on=(whereclause, whereclause.right.value),
            )

            return stmt
Exemple #6
0
def test_orm_query_new_style_ext_lambdas_cols_only(n):
    """new style ORM query w/ external lambdas against columns."""
    s = Session(bind=engine)
    for id_ in random.sample(ids, n):
        stmt = lambdas.lambda_stmt(lambda: future_select(
            Customer.id, Customer.name, Customer.description)) + (
                lambda s: s.filter(Customer.id == id_))
        s.execute(stmt).one()
Exemple #7
0
def test_orm_query_new_style_using_external_lambdas(n):
    """new style ORM select() of the full entity w/ external lambdas."""

    session = Session(bind=engine)
    for id_ in random.sample(ids, n):

        stmt = lambdas.lambda_stmt(lambda: future_select(Customer))
        stmt += lambda s: s.where(Customer.id == id_)
        session.execute(stmt).scalar_one()
Exemple #8
0
 def test_in_parameters_three(self):
     expr3 = lambdas.lambda_stmt(
         lambda: select([1]).where(column("q").in_(["a", "b", "c"]))
     )
     self.assert_compile(expr3, "SELECT 1 WHERE q IN ([POSTCOMPILE_q_1])")
     self.assert_compile(
         expr3,
         "SELECT 1 WHERE q IN (:q_1_1, :q_1_2, :q_1_3)",
         render_postcompile=True,
         checkparams={"q_1_1": "a", "q_1_2": "b", "q_1_3": "c"},
     )
Exemple #9
0
    def test_propagate_attrs_full_stmt(self):
        col = column("q")
        col._propagate_attrs = col._propagate_attrs.union(
            {"compile_state_plugin": "x", "plugin_subject": "y"}
        )

        stmt = lambdas.lambda_stmt(lambda: select([col]))

        eq_(
            stmt._propagate_attrs,
            {"compile_state_plugin": "x", "plugin_subject": "y"},
        )
Exemple #10
0
    def test_stmt_lambda_w_set_of_opts(self):

        stmt = lambdas.lambda_stmt(lambda: select(column("x")))

        opts = {column("x"), column("y")}

        assert_raises_message(
            exc.ArgumentError,
            'Can\'t create a cache key for lambda closure variable "opts" '
            "because it's a set.  try using a list",
            stmt.__add__,
            lambda stmt: stmt.options(*opts),
        )
Exemple #11
0
        def go(x, y):
            stmt = lambdas.lambda_stmt(lambda: select(column("x")))

            if x > 5:
                stmt += lambda stmt: stmt.where(column("x") == x)
            else:
                stmt += lambda stmt: stmt.where(column("y") == y)

            stmt += lambda stmt: stmt.order_by(column("q"))

            # TODO: need more path variety here to exercise
            # using a full path key

            return stmt
Exemple #12
0
        def go(x, y):

            stmt = lambdas.lambda_stmt(lambda: select(x)) + (
                lambda s: s.where(y > 5))
            return stmt
Exemple #13
0
        def go(opts):
            stmt = lambdas.lambda_stmt(lambda: select(column("x")))
            stmt += lambda stmt: stmt.options(*opts)

            return stmt
Exemple #14
0
        def go(x):

            stmt = lambdas.lambda_stmt(lambda: select(x))
            return stmt
Exemple #15
0
        def go(thing, q):
            stmt = lambdas.lambda_stmt(lambda: select(thing.col_expr))
            stmt += lambda stmt: stmt.where(thing.col_expr == q)

            return stmt
Exemple #16
0
        def go(col_expr, whereclause):
            stmt = lambdas.lambda_stmt(lambda: select(col_expr))
            stmt += lambda stmt: stmt.where(whereclause)

            return stmt
Exemple #17
0
 def go(names):
     return lambdas.lambda_stmt(
         lambda: select([1]).where(column("q").in_(names)))
Exemple #18
0
 def go(n1, n2):
     stmt = lambdas.lambda_stmt(
         lambda: select([1]).where(column("q").in_(n1)))
     stmt += lambda s: s.where(column("y").in_(n2))
     return stmt
Exemple #19
0
        def go(col_expr, q):
            stmt = lambdas.lambda_stmt(lambda: select(col_expr))
            stmt += lambda stmt: stmt.where(col_expr == q)

            return stmt