diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-09-12 08:28:54 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-09-12 08:28:54 +0000 |
commit | 7db33518a4264e422294a1e20fbd1c1505d9a62d (patch) | |
tree | aeb9ae54563b1f8f9c26fd54d0c207b082b89cd4 /tests/dialects/test_mysql.py | |
parent | Releasing debian version 18.2.0-1. (diff) | |
download | sqlglot-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 '')
-rw-r--r-- | tests/dialects/test_mysql.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/dialects/test_mysql.py b/tests/dialects/test_mysql.py index fc63f9f..1f1c2e9 100644 --- a/tests/dialects/test_mysql.py +++ b/tests/dialects/test_mysql.py @@ -6,6 +6,19 @@ class TestMySQL(Validator): dialect = "mysql" def test_ddl(self): + int_types = {"BIGINT", "INT", "MEDIUMINT", "SMALLINT", "TINYINT"} + + for t in int_types: + self.validate_identity(f"CREATE TABLE t (id {t} UNSIGNED)") + self.validate_identity(f"CREATE TABLE t (id {t}(10) UNSIGNED)") + + self.validate_all( + "CREATE TABLE t (id INT UNSIGNED)", + write={ + "duckdb": "CREATE TABLE t (id UINTEGER)", + }, + ) + self.validate_identity("CREATE TABLE foo (id BIGINT)") self.validate_identity("CREATE TABLE 00f (1d BIGINT)") self.validate_identity("UPDATE items SET items.price = 0 WHERE items.id >= 5 LIMIT 10") @@ -83,6 +96,12 @@ class TestMySQL(Validator): "mysql": "CREATE TABLE IF NOT EXISTS industry_info (a BIGINT(20) NOT NULL AUTO_INCREMENT, b BIGINT(20) NOT NULL, c VARCHAR(1000), PRIMARY KEY (a), UNIQUE d (b), INDEX e (b))", }, ) + self.validate_all( + "CREATE TABLE test (ts TIMESTAMP, ts_tz TIMESTAMPTZ, ts_ltz TIMESTAMPLTZ)", + write={ + "mysql": "CREATE TABLE test (ts DATETIME, ts_tz TIMESTAMP, ts_ltz TIMESTAMP)", + }, + ) def test_identity(self): self.validate_identity( @@ -202,6 +221,9 @@ class TestMySQL(Validator): "spark": "CAST(x AS BLOB) + CAST(y AS BLOB)", }, ) + self.validate_all("CAST(x AS TIMESTAMP)", write={"mysql": "CAST(x AS DATETIME)"}) + self.validate_all("CAST(x AS TIMESTAMPTZ)", write={"mysql": "TIMESTAMP(x)"}) + self.validate_all("CAST(x AS TIMESTAMPLTZ)", write={"mysql": "TIMESTAMP(x)"}) def test_canonical_functions(self): self.validate_identity("SELECT LEFT('str', 2)", "SELECT LEFT('str', 2)") |