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.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/tests/dialects/test_mysql.py b/tests/dialects/test_mysql.py
index 1f1c2e9..6104e3f 100644
--- a/tests/dialects/test_mysql.py
+++ b/tests/dialects/test_mysql.py
@@ -27,6 +27,9 @@ class TestMySQL(Validator):
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 `x` (`username` VARCHAR(200), PRIMARY KEY (`username`(16)))"
+ )
+ self.validate_identity(
"UPDATE items SET items.price = 0 WHERE items.id >= 5 ORDER BY items.id LIMIT 10"
)
self.validate_identity(
@@ -204,21 +207,21 @@ class TestMySQL(Validator):
self.validate_identity("CAST(x AS MEDIUMINT) + CAST(y AS YEAR(4))")
self.validate_all(
- "CAST(x AS MEDIUMTEXT) + CAST(y AS LONGTEXT)",
+ "CAST(x AS MEDIUMTEXT) + CAST(y AS LONGTEXT) + CAST(z AS TINYTEXT)",
read={
- "mysql": "CAST(x AS MEDIUMTEXT) + CAST(y AS LONGTEXT)",
+ "mysql": "CAST(x AS MEDIUMTEXT) + CAST(y AS LONGTEXT) + CAST(z AS TINYTEXT)",
},
write={
- "spark": "CAST(x AS TEXT) + CAST(y AS TEXT)",
+ "spark": "CAST(x AS TEXT) + CAST(y AS TEXT) + CAST(z AS TEXT)",
},
)
self.validate_all(
- "CAST(x AS MEDIUMBLOB) + CAST(y AS LONGBLOB)",
+ "CAST(x AS MEDIUMBLOB) + CAST(y AS LONGBLOB) + CAST(z AS TINYBLOB)",
read={
- "mysql": "CAST(x AS MEDIUMBLOB) + CAST(y AS LONGBLOB)",
+ "mysql": "CAST(x AS MEDIUMBLOB) + CAST(y AS LONGBLOB) + CAST(z AS TINYBLOB)",
},
write={
- "spark": "CAST(x AS BLOB) + CAST(y AS BLOB)",
+ "spark": "CAST(x AS BLOB) + CAST(y AS BLOB) + CAST(z AS BLOB)",
},
)
self.validate_all("CAST(x AS TIMESTAMP)", write={"mysql": "CAST(x AS DATETIME)"})
@@ -240,6 +243,15 @@ class TestMySQL(Validator):
)
def test_escape(self):
+ self.validate_identity("""'"abc"'""")
+ self.validate_identity(
+ r"'\'a'",
+ "'''a'",
+ )
+ self.validate_identity(
+ '''"'abc'"''',
+ "'''abc'''",
+ )
self.validate_all(
r"'a \' b '' '",
write={
@@ -525,6 +537,7 @@ class TestMySQL(Validator):
"mysql": "SELECT DATE(DATE_SUB(`dt`, INTERVAL (DAYOFMONTH(`dt`) - 1) DAY)) AS __timestamp FROM tableT",
},
)
+ self.validate_identity("SELECT name FROM temp WHERE name = ? FOR UPDATE")
self.validate_all(
"SELECT a FROM tbl FOR UPDATE",
write={