MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_global_tracking

Method test_global_tracking

test/sql/test_lambdas.py:87–114  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

85 )
86
87 def test_global_tracking(self):
88 t1 = table("t1", column("q"), column("p"))
89
90 global global_x, global_y
91
92 global_x = 10
93 global_y = 17
94
95 def go():
96 return select(t1).where(
97 lambda: and_(t1.c.q == global_x, t1.c.p == global_y)
98 )
99
100 self.assert_compile(
101 go(),
102 "SELECT t1.q, t1.p FROM t1 WHERE t1.q = :global_x_1 "
103 "AND t1.p = :global_y_1",
104 checkparams={"global_x_1": 10, "global_y_1": 17},
105 )
106
107 global_y = 9
108
109 self.assert_compile(
110 go(),
111 "SELECT t1.q, t1.p FROM t1 WHERE t1.q = :global_x_1 "
112 "AND t1.p = :global_y_1",
113 checkparams={"global_x_1": 10, "global_y_1": 9},
114 )
115
116 def test_boolean_constants(self):
117 t1 = table("t1", column("q"), column("p"))

Callers

nothing calls this directly

Calls 4

tableFunction · 0.90
columnFunction · 0.90
assert_compileMethod · 0.80
goFunction · 0.50

Tested by

no test coverage detected