From a8cfe41f416430cab0d6aa0ff6a688b2832a39aa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 9 Oct 2024 08:28:52 +0200 Subject: Merging upstream version 25.24.5. Signed-off-by: Daniel Baumann --- tests/test_build.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests/test_build.py') diff --git a/tests/test_build.py b/tests/test_build.py index 7518b72..5d383ad 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -577,6 +577,36 @@ class TestBuild(unittest.TestCase): lambda: exp.update("tbl", {"x": 1}, from_="tbl2 cross join tbl3"), "UPDATE tbl SET x = 1 FROM tbl2 CROSS JOIN tbl3", ), + ( + lambda: exp.update( + "my_table", + {"x": 1}, + from_="baz", + where="my_table.id = baz.id", + with_={"baz": "SELECT id FROM foo UNION SELECT id FROM bar"}, + ), + "WITH baz AS (SELECT id FROM foo UNION SELECT id FROM bar) UPDATE my_table SET x = 1 FROM baz WHERE my_table.id = baz.id", + ), + ( + lambda: exp.update("my_table").set_("x = 1"), + "UPDATE my_table SET x = 1", + ), + ( + lambda: exp.update("my_table").set_("x = 1").where("y = 2"), + "UPDATE my_table SET x = 1 WHERE y = 2", + ), + ( + lambda: exp.update("my_table").set_("a = 1").set_("b = 2"), + "UPDATE my_table SET a = 1, b = 2", + ), + ( + lambda: exp.update("my_table") + .set_("x = 1") + .where("my_table.id = baz.id") + .from_("baz") + .with_("baz", "SELECT id FROM foo"), + "WITH baz AS (SELECT id FROM foo) UPDATE my_table SET x = 1 FROM baz WHERE my_table.id = baz.id", + ), ( lambda: union("SELECT * FROM foo", "SELECT * FROM bla"), "SELECT * FROM foo UNION SELECT * FROM bla", -- cgit v1.2.3