summaryrefslogtreecommitdiffstats
path: root/tests/test_build.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-10-09 06:28:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-10-09 06:28:52 +0000
commita8cfe41f416430cab0d6aa0ff6a688b2832a39aa (patch)
treedd48a1d853317a0daaaf3e2f6868e01dbad936e7 /tests/test_build.py
parentReleasing debian version 25.24.0-1. (diff)
downloadsqlglot-a8cfe41f416430cab0d6aa0ff6a688b2832a39aa.tar.xz
sqlglot-a8cfe41f416430cab0d6aa0ff6a688b2832a39aa.zip
Merging upstream version 25.24.5.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_build.py')
-rw-r--r--tests/test_build.py30
1 files changed, 30 insertions, 0 deletions
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
@@ -578,6 +578,36 @@ class TestBuild(unittest.TestCase):
"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",
),