File tree Expand file tree Collapse file tree 3 files changed +49
-1
lines changed
Expand file tree Collapse file tree 3 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,14 @@ def exceptional_cases(self, value: str) -> bool:
168168 return True
169169 return False
170170
171+ def t_COLLATE (self , t : LexToken ):
172+ r"(?i:COLLATE|COLLATE)\b"
173+ if not self .lexer .after_columns :
174+ t .type = "COLLATE"
175+ else :
176+ t .type = "ID"
177+ return self .set_last_token (t )
178+
171179 def t_AUTOINCREMENT (self , t : LexToken ):
172180 r"(?i:AUTO_INCREMENT|AUTOINCREMENT)\b"
173181 if not self .lexer .after_columns :
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ class SparkSQL(Dialect):
8686
8787@dataclass
8888@dialect (name = "mysql" )
89- class MySSQL (Dialect ):
89+ class MySQL (Dialect ):
9090 engine : Optional [str ] = field (
9191 default = None , metadata = {"exclude_if_not_provided" : True }
9292 )
Original file line number Diff line number Diff line change @@ -592,3 +592,43 @@ def test_column_index():
592592 ]
593593
594594 assert result == expected
595+
596+
597+ def test_table_properties ():
598+ ddl = """CREATE TABLE `posts`(
599+ `integer_column__index` INT NOT NULL INDEX
600+ ) ENGINE=InnoDB AUTO_INCREMENT=4682 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='test';"""
601+
602+ result = DDLParser (ddl ).run (output_mode = "mysql" )
603+ expected = [
604+ {
605+ "alter" : {},
606+ "checks" : [],
607+ "auto_increment" : "4682" ,
608+ "columns" : [
609+ {
610+ "check" : None ,
611+ "default" : None ,
612+ "index" : True ,
613+ "name" : "`integer_column__index`" ,
614+ "nullable" : False ,
615+ "references" : None ,
616+ "size" : None ,
617+ "type" : "INT" ,
618+ "unique" : False ,
619+ }
620+ ],
621+ "comment" : "'test'" ,
622+ "default_charset" : "utf8mb4" ,
623+ "engine" : "InnoDB" ,
624+ "index" : [],
625+ "partitioned_by" : [],
626+ "primary_key" : [],
627+ "schema" : None ,
628+ "table_name" : "`posts`" ,
629+ "tablespace" : None ,
630+ "table_properties" : {"collate" : "utf8mb4_unicode_ci" }
631+ }
632+ ]
633+ assert result == expected
634+
You can’t perform that action at this time.
0 commit comments