summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_postgres.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-12 08:28:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-12 08:28:50 +0000
commite0020988fe4406db67049553541a0d20e877209c (patch)
treef1647ad6cf825919eb9ef327878db3df708189e9 /tests/dialects/test_postgres.py
parentAdding upstream version 18.2.0. (diff)
downloadsqlglot-e0020988fe4406db67049553541a0d20e877209c.tar.xz
sqlglot-e0020988fe4406db67049553541a0d20e877209c.zip
Adding upstream version 18.3.0.upstream/18.3.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_postgres.py')
-rw-r--r--tests/dialects/test_postgres.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/dialects/test_postgres.py b/tests/dialects/test_postgres.py
index 8740aca..21196b7 100644
--- a/tests/dialects/test_postgres.py
+++ b/tests/dialects/test_postgres.py
@@ -126,12 +126,17 @@ class TestPostgres(Validator):
)
def test_postgres(self):
- self.validate_identity("x @@ y")
-
expr = parse_one("SELECT * FROM r CROSS JOIN LATERAL UNNEST(ARRAY[1]) AS s(location)")
unnest = expr.args["joins"][0].this.this
unnest.assert_is(exp.Unnest)
+ alter_table_only = """ALTER TABLE ONLY "Album" ADD CONSTRAINT "FK_AlbumArtistId" FOREIGN KEY ("ArtistId") REFERENCES "Artist" ("ArtistId") ON DELETE NO ACTION ON UPDATE NO ACTION"""
+ expr = parse_one(alter_table_only)
+
+ self.assertIsInstance(expr, exp.AlterTable)
+ self.assertEqual(expr.sql(dialect="postgres"), alter_table_only)
+
+ self.validate_identity("x @@ y")
self.validate_identity("CAST(x AS MONEY)")
self.validate_identity("CAST(x AS INT4RANGE)")
self.validate_identity("CAST(x AS INT4MULTIRANGE)")
@@ -619,6 +624,12 @@ class TestPostgres(Validator):
"snowflake": "MERGE INTO x USING (SELECT id) AS y ON a = b WHEN MATCHED THEN UPDATE SET x.a = y.b",
},
)
+ self.validate_all(
+ "MERGE INTO x USING (SELECT id) AS y ON a = b WHEN MATCHED THEN UPDATE SET x.a = y.b WHEN NOT MATCHED THEN INSERT (a, b) VALUES (y.a, y.b)",
+ write={
+ "postgres": "MERGE INTO x USING (SELECT id) AS y ON a = b WHEN MATCHED THEN UPDATE SET a = y.b WHEN NOT MATCHED THEN INSERT (a, b) VALUES (y.a, y.b)",
+ },
+ )
self.validate_all(
"x / y ^ z",