From f73e9af131151f1e058446361c35b05c4c90bf10 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 7 Sep 2023 13:39:48 +0200 Subject: Merging upstream version 18.2.0. Signed-off-by: Daniel Baumann --- tests/dialects/test_mysql.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests/dialects/test_mysql.py') diff --git a/tests/dialects/test_mysql.py b/tests/dialects/test_mysql.py index d60f09d..fc63f9f 100644 --- a/tests/dialects/test_mysql.py +++ b/tests/dialects/test_mysql.py @@ -7,11 +7,15 @@ class TestMySQL(Validator): def test_ddl(self): 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") 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( + "UPDATE items SET items.price = 0 WHERE items.id >= 5 ORDER BY items.id LIMIT 10" + ) self.validate_identity( "CREATE TABLE foo (a BIGINT, INDEX b USING HASH (c) COMMENT 'd' VISIBLE ENGINE_ATTRIBUTE = 'e' WITH PARSER foo)" ) @@ -81,6 +85,9 @@ class TestMySQL(Validator): ) def test_identity(self): + self.validate_identity( + "SELECT * FROM x ORDER BY BINARY a", "SELECT * FROM x ORDER BY CAST(a AS BINARY)" + ) self.validate_identity("SELECT 1 XOR 0") self.validate_identity("SELECT 1 && 0", "SELECT 1 AND 0") self.validate_identity("SELECT /*+ BKA(t1) NO_BKA(t2) */ * FROM t1 INNER JOIN t2") @@ -171,8 +178,12 @@ class TestMySQL(Validator): self.validate_identity( "SET @@GLOBAL.sort_buffer_size = 1000000, @@LOCAL.sort_buffer_size = 1000000" ) + self.validate_identity("INTERVAL '1' YEAR") + self.validate_identity("DATE_ADD(x, INTERVAL 1 YEAR)") def test_types(self): + self.validate_identity("CAST(x AS MEDIUMINT) + CAST(y AS YEAR(4))") + self.validate_all( "CAST(x AS MEDIUMTEXT) + CAST(y AS LONGTEXT)", read={ @@ -353,6 +364,7 @@ class TestMySQL(Validator): write={ "": "MATCH(col1, col2, col3) AGAINST('abc')", "mysql": "MATCH(col1, col2, col3) AGAINST('abc')", + "postgres": "(col1 @@ 'abc' OR col2 @@ 'abc' OR col3 @@ 'abc')", # not quite correct because it's not ts_query }, ) self.validate_all( @@ -818,3 +830,6 @@ COMMENT='客户账户表'""" cmd = self.parse_one("SET x = 1, y = 2") self.assertEqual(len(cmd.expressions), 2) + + def test_json_object(self): + self.validate_identity("SELECT JSON_OBJECT('id', 87, 'name', 'carrot')") -- cgit v1.2.3