diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-01-31 05:44:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-01-31 05:44:37 +0000 |
commit | 5f8be2e0852f3c925fb873a48946caee3050899f (patch) | |
tree | 1f31666277e226f47180321c08be7ebbedc2780e /tests/dialects/test_dialect.py | |
parent | Adding upstream version 20.9.0. (diff) | |
download | sqlglot-5f8be2e0852f3c925fb873a48946caee3050899f.tar.xz sqlglot-5f8be2e0852f3c925fb873a48946caee3050899f.zip |
Adding upstream version 20.11.0.upstream/20.11.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_dialect.py')
-rw-r--r-- | tests/dialects/test_dialect.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/dialects/test_dialect.py b/tests/dialects/test_dialect.py index 3cf4ddc..22e7d49 100644 --- a/tests/dialects/test_dialect.py +++ b/tests/dialects/test_dialect.py @@ -11,6 +11,7 @@ from sqlglot import ( parse_one, ) from sqlglot.dialects import BigQuery, Hive, Snowflake +from sqlglot.parser import logger as parser_logger class Validator(unittest.TestCase): @@ -19,8 +20,14 @@ class Validator(unittest.TestCase): def parse_one(self, sql): return parse_one(sql, read=self.dialect) - def validate_identity(self, sql, write_sql=None, pretty=False): - expression = self.parse_one(sql) + def validate_identity(self, sql, write_sql=None, pretty=False, check_command_warning=False): + if check_command_warning: + with self.assertLogs(parser_logger) as cm: + expression = self.parse_one(sql) + assert f"'{sql[:100]}' contains unsupported syntax" in cm.output[0] + else: + expression = self.parse_one(sql) + self.assertEqual(write_sql or sql, expression.sql(dialect=self.dialect, pretty=pretty)) return expression |