MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_update_to_expression_two

Method test_update_to_expression_two

test/sql/test_update.py:896–927  ·  view source on GitHub ↗

test update from an expression. this logic is triggered currently by a left side that doesn't have a key. The current supported use case is updating the index of a PostgreSQL ARRAY type.

(self, t, idx_to_value)

Source from the content-addressed store, hash-verified

894
895 @random_update_order_parameters()
896 def test_update_to_expression_two(self, t, idx_to_value):
897 """test update from an expression.
898
899 this logic is triggered currently by a left side that doesn't
900 have a key. The current supported use case is updating the index
901 of a PostgreSQL ARRAY type.
902
903 """
904
905 dialect = default.StrCompileDialect()
906 dialect.paramstyle = "qmark"
907 dialect.positional = True
908
909 stmt = t.update().ordered_values(
910 *[(col[idx], val) for col, idx, val in idx_to_value]
911 )
912
913 self.assert_compile(
914 stmt,
915 "UPDATE foo SET %s"
916 % (
917 ", ".join(
918 "%s[?]=?" % col.key for col, idx, val in idx_to_value
919 )
920 ),
921 dialect=dialect,
922 checkpositional=tuple(
923 itertools.chain.from_iterable(
924 (idx, val) for col, idx, val in idx_to_value
925 )
926 ),
927 )
928
929 def test_update_to_expression_three(self):
930 # this test is from test_defaults but exercises a particular

Callers

nothing calls this directly

Calls 4

ordered_valuesMethod · 0.80
assert_compileMethod · 0.80
updateMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected