MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_functions_with_cols

Method test_functions_with_cols

test/sql/test_functions.py:677–715  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

675 )
676
677 def test_functions_with_cols(self):
678 users = table(
679 "users", column("id"), column("name"), column("fullname")
680 )
681 calculate = (
682 select(column("q"), column("z"), column("r"))
683 .select_from(
684 func.calculate(bindparam("x", None), bindparam("y", None))
685 )
686 .subquery()
687 )
688
689 self.assert_compile(
690 select(users).where(users.c.id > calculate.c.z),
691 "SELECT users.id, users.name, users.fullname "
692 "FROM users, (SELECT q, z, r "
693 "FROM calculate(:x, :y)) AS anon_1 "
694 "WHERE users.id > anon_1.z",
695 )
696
697 with expect_deprecated(
698 r"The params\(\) and unique_params\(\) methods on non-statement"
699 ):
700 s = select(users).where(
701 users.c.id.between(
702 calculate.alias("c1").unique_params(x=17, y=45).c.z,
703 calculate.alias("c2").unique_params(x=5, y=12).c.z,
704 ),
705 )
706
707 self.assert_compile(
708 s,
709 "SELECT users.id, users.name, users.fullname "
710 "FROM users, (SELECT q, z, r "
711 "FROM calculate(:x_1, :y_1)) AS c1, (SELECT q, z, r "
712 "FROM calculate(:x_2, :y_2)) AS c2 "
713 "WHERE users.id BETWEEN c1.z AND c2.z",
714 checkparams={"y_1": 45, "x_1": 17, "y_2": 12, "x_2": 5},
715 )
716
717 def test_non_functions(self):
718 expr = func.cast("foo", Integer)

Callers

nothing calls this directly

Calls 12

tableFunction · 0.90
columnFunction · 0.90
selectFunction · 0.90
bindparamFunction · 0.90
expect_deprecatedFunction · 0.90
assert_compileMethod · 0.80
subqueryMethod · 0.45
select_fromMethod · 0.45
whereMethod · 0.45
betweenMethod · 0.45
unique_paramsMethod · 0.45
aliasMethod · 0.45

Tested by

no test coverage detected