test bind params named after column names replace the normal SET/VALUES generation. See also test_compiler.py::CrudParamOverlapTest
(self)
| 380 | ) |
| 381 | |
| 382 | def test_binds_that_match_columns(self): |
| 383 | class="st">"""test bind params named after column names |
| 384 | replace the normal SET/VALUES generation. |
| 385 | |
| 386 | See also test_compiler.py::CrudParamOverlapTest |
| 387 | |
| 388 | class="st">""" |
| 389 | |
| 390 | t = table(class="st">"foo", column(class="st">"x"), column(class="st">"y")) |
| 391 | |
| 392 | u = t.update().where(t.c.x == bindparam(class="st">"x")) |
| 393 | |
| 394 | assert_raises(exc.CompileError, u.compile) |
| 395 | |
| 396 | self.assert_compile(u, class="st">"UPDATE foo SET WHERE foo.x = :x", params={}) |
| 397 | |
| 398 | assert_raises(exc.CompileError, u.values(x=7).compile) |
| 399 | |
| 400 | self.assert_compile( |
| 401 | u.values(y=7), class="st">"UPDATE foo SET y=:y WHERE foo.x = :x" |
| 402 | ) |
| 403 | |
| 404 | assert_raises( |
| 405 | exc.CompileError, u.values(x=7).compile, column_keys=[class="st">"x", class="st">"y"] |
| 406 | ) |
| 407 | assert_raises(exc.CompileError, u.compile, column_keys=[class="st">"x", class="st">"y"]) |
| 408 | |
| 409 | self.assert_compile( |
| 410 | u.values(x=3 + bindparam(class="st">"x")), |
| 411 | class="st">"UPDATE foo SET x=(:param_1 + :x) WHERE foo.x = :x", |
| 412 | ) |
| 413 | |
| 414 | self.assert_compile( |
| 415 | u.values(x=3 + bindparam(class="st">"x")), |
| 416 | class="st">"UPDATE foo SET x=(:param_1 + :x) WHERE foo.x = :x", |
| 417 | params={class="st">"x": 1}, |
| 418 | ) |
| 419 | |
| 420 | self.assert_compile( |
| 421 | u.values(x=3 + bindparam(class="st">"x")), |
| 422 | class="st">"UPDATE foo SET x=(:param_1 + :x), y=:y WHERE foo.x = :x", |
| 423 | params={class="st">"x": 1, class="st">"y": 2}, |
| 424 | ) |
| 425 | |
| 426 | def test_labels_no_collision(self): |
| 427 | t = table(class="st">"foo", column(class="st">"id"), column(class="st">"foo_id")) |
nothing calls this directly
no test coverage detected