MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_update_to_expression_three

Method test_update_to_expression_three

test/sql/test_update.py:929–965  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

927 )
928
929 def test_update_to_expression_three(self):
930 # this test is from test_defaults but exercises a particular
931 # parameter ordering issue
932 metadata = MetaData()
933
934 q = Table(
935 "q",
936 metadata,
937 Column("x", Integer, default=2),
938 Column("y", Integer, onupdate=5),
939 Column("z", Integer),
940 )
941
942 p = Table(
943 "p",
944 metadata,
945 Column("s", Integer),
946 Column("t", Integer),
947 Column("u", Integer, onupdate=1),
948 )
949
950 cte = (
951 q.update().where(q.c.z == 1).values(x=7).returning(q.c.z).cte("c")
952 )
953 stmt = select(p.c.s, cte.c.z).where(p.c.s == cte.c.z)
954
955 dialect = default.StrCompileDialect()
956 dialect.paramstyle = "qmark"
957 dialect.positional = True
958
959 self.assert_compile(
960 stmt,
961 "WITH c AS (UPDATE q SET x=?, y=? WHERE q.z = ? RETURNING q.z) "
962 "SELECT p.s, c.z FROM p, c WHERE p.s = c.z",
963 checkpositional=(7, None, 1),
964 dialect=dialect,
965 )
966
967 @testing.variation("paramstyle", ["qmark", "format", "numeric"])
968 def test_update_bound_ordering(self, paramstyle):

Callers

nothing calls this directly

Calls 10

MetaDataClass · 0.90
TableClass · 0.90
ColumnClass · 0.90
selectFunction · 0.90
assert_compileMethod · 0.80
cteMethod · 0.45
returningMethod · 0.45
valuesMethod · 0.45
whereMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected