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:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-12 08:28:54 +0000
commit7db33518a4264e422294a1e20fbd1c1505d9a62d (patch)
treeaeb9ae54563b1f8f9c26fd54d0c207b082b89cd4 /tests/dialects/test_postgres.py
parentReleasing debian version 18.2.0-1. (diff)
downloadsqlglot-7db33518a4264e422294a1e20fbd1c1505d9a62d.tar.xz
sqlglot-7db33518a4264e422294a1e20fbd1c1505d9a62d.zip
Merging upstream version 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",