MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_dml_ctes

Method test_dml_ctes

test/orm/test_core_compilation.py:560–587  ·  view source on GitHub ↗
(self, stmt_type: testing.Variation)

Source from the content-addressed store, hash-verified

558
559 @testing.variation("stmt_type", ["update", "delete"])
560 def test_dml_ctes(self, stmt_type: testing.Variation):
561 User = self.classes.User
562
563 if stmt_type.update:
564 fn = update
565 elif stmt_type.delete:
566 fn = delete
567 else:
568 stmt_type.fail()
569
570 inner_cte = fn(User).returning(User.id).cte("uid")
571
572 stmt = select(inner_cte)
573
574 if stmt_type.update:
575 self.assert_compile(
576 stmt,
577 "WITH uid AS (UPDATE users SET id=:id, name=:name "
578 "RETURNING users.id) SELECT uid.id FROM uid",
579 )
580 elif stmt_type.delete:
581 self.assert_compile(
582 stmt,
583 "WITH uid AS (DELETE FROM users "
584 "RETURNING users.id) SELECT uid.id FROM uid",
585 )
586 else:
587 stmt_type.fail()
588
589 @testing.variation("stmt_type", ["core", "orm"])
590 def test_aliased_update(self, stmt_type: testing.Variation):

Callers

nothing calls this directly

Calls 5

selectFunction · 0.90
assert_compileMethod · 0.80
failMethod · 0.45
cteMethod · 0.45
returningMethod · 0.45

Tested by

no test coverage detected