MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_update_limit

Method test_update_limit

test/dialect/mysql/test_compiler.py:883–915  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

881 )
882
883 def test_update_limit(self):
884 t = sql.table("t", sql.column("col1"), sql.column("col2"))
885
886 self.assert_compile(
887 t.update().values({"col1": 123}), "UPDATE t SET col1=%s"
888 )
889 self.assert_compile(
890 t.update()
891 .values({"col1": 123})
892 .with_dialect_options(mysql_limit=5),
893 "UPDATE t SET col1=%s LIMIT 5",
894 )
895
896 # does not make sense but we want this to compile
897 self.assert_compile(
898 t.update()
899 .values({"col1": 123})
900 .with_dialect_options(mysql_limit=0),
901 "UPDATE t SET col1=%s LIMIT 0",
902 )
903 self.assert_compile(
904 t.update()
905 .values({"col1": 123})
906 .with_dialect_options(mysql_limit=None),
907 "UPDATE t SET col1=%s",
908 )
909 self.assert_compile(
910 t.update()
911 .where(t.c.col2 == 456)
912 .values({"col1": 123})
913 .with_dialect_options(mysql_limit=1),
914 "UPDATE t SET col1=%s WHERE t.col2 = %s LIMIT 1",
915 )
916
917 def test_delete_limit(self):
918 t = sql.table("t", sql.column("col1"), sql.column("col2"))

Callers

nothing calls this directly

Calls 7

assert_compileMethod · 0.80
with_dialect_optionsMethod · 0.80
tableMethod · 0.45
columnMethod · 0.45
valuesMethod · 0.45
updateMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected