From 379c6d1f52e1d311867c4f789dc389da1d9af898 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 6 Aug 2023 09:48:11 +0200 Subject: Merging upstream version 17.9.1. Signed-off-by: Daniel Baumann --- tests/dialects/test_mysql.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/dialects/test_mysql.py') diff --git a/tests/dialects/test_mysql.py b/tests/dialects/test_mysql.py index ae2fa41..d021d62 100644 --- a/tests/dialects/test_mysql.py +++ b/tests/dialects/test_mysql.py @@ -9,6 +9,12 @@ class TestMySQL(Validator): self.validate_identity("CREATE TABLE foo (id BIGINT)") self.validate_identity("UPDATE items SET items.price = 0 WHERE items.id >= 5 LIMIT 10") self.validate_identity("DELETE FROM t WHERE a <= 10 LIMIT 10") + self.validate_identity("CREATE TABLE foo (a BIGINT, INDEX USING BTREE (b))") + self.validate_identity("CREATE TABLE foo (a BIGINT, FULLTEXT INDEX (b))") + self.validate_identity("CREATE TABLE foo (a BIGINT, SPATIAL INDEX (b))") + self.validate_identity( + "CREATE TABLE foo (a BIGINT, INDEX b USING HASH (c) COMMENT 'd' VISIBLE ENGINE_ATTRIBUTE = 'e' WITH PARSER foo)" + ) self.validate_identity( "DELETE t1 FROM t1 LEFT JOIN t2 ON t1.id = t2.id WHERE t2.id IS NULL" ) @@ -67,6 +73,12 @@ class TestMySQL(Validator): "mysql": "CREATE TABLE `foo` (`id` CHAR(36) NOT NULL DEFAULT (UUID()), PRIMARY KEY (`id`), UNIQUE `id` (`id`))", }, ) + self.validate_all( + "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 KEY d (b), KEY e (b))", + write={ + "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))", + }, + ) def test_identity(self): self.validate_identity("SELECT 1 XOR 0") @@ -436,6 +448,13 @@ class TestMySQL(Validator): self.validate_identity("TIME_STR_TO_UNIX(x)", "UNIX_TIMESTAMP(x)") def test_mysql(self): + self.validate_all( + "SELECT * FROM test LIMIT 0 + 1, 0 + 1", + write={ + "mysql": "SELECT * FROM test LIMIT 1 OFFSET 1", + "postgres": "SELECT * FROM test LIMIT 0 + 1 OFFSET 0 + 1", + }, + ) self.validate_all( "CAST(x AS TEXT)", write={ @@ -448,6 +467,7 @@ class TestMySQL(Validator): self.validate_all("CAST(x AS SIGNED INTEGER)", write={"mysql": "CAST(x AS SIGNED)"}) self.validate_all("CAST(x AS UNSIGNED)", write={"mysql": "CAST(x AS UNSIGNED)"}) self.validate_all("CAST(x AS UNSIGNED INTEGER)", write={"mysql": "CAST(x AS UNSIGNED)"}) + self.validate_all("TIME_STR_TO_TIME(x)", write={"mysql": "CAST(x AS DATETIME)"}) self.validate_all( """SELECT 17 MEMBER OF('[23, "abc", 17, "ab", 10]')""", write={ -- cgit v1.2.3