From 7db33518a4264e422294a1e20fbd1c1505d9a62d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 12 Sep 2023 10:28:54 +0200 Subject: Merging upstream version 18.3.0. Signed-off-by: Daniel Baumann --- tests/dialects/test_postgres.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'tests/dialects/test_postgres.py') 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", -- cgit v1.2.3