summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_mysql.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dialects/test_mysql.py')
-rw-r--r--tests/dialects/test_mysql.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/tests/dialects/test_mysql.py b/tests/dialects/test_mysql.py
index 6104e3f..e362e9e 100644
--- a/tests/dialects/test_mysql.py
+++ b/tests/dialects/test_mysql.py
@@ -19,6 +19,7 @@ class TestMySQL(Validator):
},
)
+ self.validate_identity("CREATE TABLE foo (a BIGINT, UNIQUE (b) USING BTREE)")
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")
@@ -107,9 +108,8 @@ 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("UNLOCK TABLES")
+ self.validate_identity("LOCK TABLES `app_fields` WRITE")
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")
@@ -134,6 +134,9 @@ class TestMySQL(Validator):
self.validate_identity("SELECT * FROM t1, t2 FOR SHARE OF t1, t2 SKIP LOCKED")
self.validate_identity("SELECT a || b", "SELECT a OR b")
self.validate_identity(
+ "SELECT * FROM x ORDER BY BINARY a", "SELECT * FROM x ORDER BY CAST(a AS BINARY)"
+ )
+ self.validate_identity(
"""SELECT * FROM foo WHERE 3 MEMBER OF(JSON_EXTRACT(info, '$.value'))"""
)
self.validate_identity(
@@ -546,7 +549,7 @@ class TestMySQL(Validator):
"oracle": "SELECT a FROM tbl FOR UPDATE",
"postgres": "SELECT a FROM tbl FOR UPDATE",
"redshift": "SELECT a FROM tbl",
- "tsql": "SELECT a FROM tbl FOR UPDATE",
+ "tsql": "SELECT a FROM tbl",
},
)
self.validate_all(
@@ -556,7 +559,7 @@ class TestMySQL(Validator):
"mysql": "SELECT a FROM tbl FOR SHARE",
"oracle": "SELECT a FROM tbl FOR SHARE",
"postgres": "SELECT a FROM tbl FOR SHARE",
- "tsql": "SELECT a FROM tbl FOR SHARE",
+ "tsql": "SELECT a FROM tbl",
},
)
self.validate_all(
@@ -868,3 +871,17 @@ COMMENT='客户账户表'"""
def test_json_object(self):
self.validate_identity("SELECT JSON_OBJECT('id', 87, 'name', 'carrot')")
+
+ def test_is_null(self):
+ self.validate_all(
+ "SELECT ISNULL(x)", write={"": "SELECT (x IS NULL)", "mysql": "SELECT (x IS NULL)"}
+ )
+
+ def test_monthname(self):
+ self.validate_all(
+ "MONTHNAME(x)",
+ write={
+ "": "TIME_TO_STR(x, '%B')",
+ "mysql": "DATE_FORMAT(x, '%M')",
+ },
+ )