summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_postgres.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-07 11:39:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-07 11:39:43 +0000
commit341eb1a6bdf0dd5b015e5140d3b068c6fd3f4d87 (patch)
tree61fb7eca2238fb5d41d3906f4af41de03abd25ea /tests/dialects/test_postgres.py
parentAdding upstream version 17.12.0. (diff)
downloadsqlglot-341eb1a6bdf0dd5b015e5140d3b068c6fd3f4d87.tar.xz
sqlglot-341eb1a6bdf0dd5b015e5140d3b068c6fd3f4d87.zip
Adding upstream version 18.2.0.upstream/18.2.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.py52
1 files changed, 51 insertions, 1 deletions
diff --git a/tests/dialects/test_postgres.py b/tests/dialects/test_postgres.py
index a7719a9..8740aca 100644
--- a/tests/dialects/test_postgres.py
+++ b/tests/dialects/test_postgres.py
@@ -126,6 +126,8 @@ 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)
@@ -535,6 +537,54 @@ class TestPostgres(Validator):
write={"postgres": "CAST(x AS CSTRING)"},
)
self.validate_all(
+ "x::oid",
+ write={"postgres": "CAST(x AS OID)"},
+ )
+ self.validate_all(
+ "x::regclass",
+ write={"postgres": "CAST(x AS REGCLASS)"},
+ )
+ self.validate_all(
+ "x::regcollation",
+ write={"postgres": "CAST(x AS REGCOLLATION)"},
+ )
+ self.validate_all(
+ "x::regconfig",
+ write={"postgres": "CAST(x AS REGCONFIG)"},
+ )
+ self.validate_all(
+ "x::regdictionary",
+ write={"postgres": "CAST(x AS REGDICTIONARY)"},
+ )
+ self.validate_all(
+ "x::regnamespace",
+ write={"postgres": "CAST(x AS REGNAMESPACE)"},
+ )
+ self.validate_all(
+ "x::regoper",
+ write={"postgres": "CAST(x AS REGOPER)"},
+ )
+ self.validate_all(
+ "x::regoperator",
+ write={"postgres": "CAST(x AS REGOPERATOR)"},
+ )
+ self.validate_all(
+ "x::regproc",
+ write={"postgres": "CAST(x AS REGPROC)"},
+ )
+ self.validate_all(
+ "x::regprocedure",
+ write={"postgres": "CAST(x AS REGPROCEDURE)"},
+ )
+ self.validate_all(
+ "x::regrole",
+ write={"postgres": "CAST(x AS REGROLE)"},
+ )
+ self.validate_all(
+ "x::regtype",
+ write={"postgres": "CAST(x AS REGTYPE)"},
+ )
+ self.validate_all(
"TRIM(BOTH 'as' FROM 'as string as')",
write={
"postgres": "TRIM(BOTH 'as' FROM 'as string as')",
@@ -606,7 +656,7 @@ class TestPostgres(Validator):
"a || b",
write={
"": "a || b",
- "clickhouse": "CONCAT(CAST(a AS TEXT), CAST(b AS TEXT))",
+ "clickhouse": "CONCAT(CAST(a AS String), CAST(b AS String))",
"duckdb": "a || b",
"postgres": "a || b",
"presto": "CONCAT(CAST(a AS VARCHAR), CAST(b AS VARCHAR))",