summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_mysql.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-12 08:28:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-09-12 08:28:50 +0000
commite0020988fe4406db67049553541a0d20e877209c (patch)
treef1647ad6cf825919eb9ef327878db3df708189e9 /tests/dialects/test_mysql.py
parentAdding upstream version 18.2.0. (diff)
downloadsqlglot-e0020988fe4406db67049553541a0d20e877209c.tar.xz
sqlglot-e0020988fe4406db67049553541a0d20e877209c.zip
Adding upstream version 18.3.0.upstream/18.3.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/dialects/test_mysql.py')
-rw-r--r--tests/dialects/test_mysql.py22
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)")