mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
+10
@@ -44,6 +44,8 @@ public class MySqlCreateTableStatement extends SQLCreateTableStatement implement
|
||||
|
||||
private List<SQLCommentHint> hints = new ArrayList<SQLCommentHint>();
|
||||
|
||||
private List<SQLCommentHint> optionHints = new ArrayList<SQLCommentHint>();
|
||||
|
||||
private SQLExprTableSource like;
|
||||
|
||||
public MySqlCreateTableStatement(){
|
||||
@@ -156,4 +158,12 @@ public class MySqlCreateTableStatement extends SQLCreateTableStatement implement
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<SQLCommentHint> getOptionHints() {
|
||||
return optionHints;
|
||||
}
|
||||
|
||||
public void setOptionHints(List<SQLCommentHint> optionHints) {
|
||||
this.optionHints = optionHints;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -559,7 +559,10 @@ public class MySqlCreateTableParser extends SQLCreateTableParser {
|
||||
SQLSelect query = new MySqlSelectParser(this.exprParser).select();
|
||||
stmt.setQuery(query);
|
||||
}
|
||||
|
||||
|
||||
while (lexer.token() == (Token.HINT)) {
|
||||
this.exprParser.parseHints(stmt.getOptionHints());
|
||||
}
|
||||
return stmt;
|
||||
}
|
||||
|
||||
|
||||
@@ -497,6 +497,10 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
decrementIndent();
|
||||
}
|
||||
|
||||
for (SQLCommentHint hint : x.getOptionHints()) {
|
||||
print(' ');
|
||||
hint.accept(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,4 +95,19 @@ public class MySqlWallTest_hint extends TestCase {
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(sql)); //
|
||||
}
|
||||
|
||||
public void test_true_9() throws Exception {
|
||||
WallConfig config = new WallConfig();
|
||||
config.setHintAllow(true);
|
||||
config.setMultiStatementAllow(true);
|
||||
String sql = "CREATE TABLE `session` ("//
|
||||
+ " `sess_id` varchar(128) NOT NULL,"//
|
||||
+ " `created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',"//
|
||||
+ " `changed` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',"//
|
||||
+ " `ip` varchar(40) NOT NULL,"//
|
||||
+ " `vars` mediumtext NOT NULL,"//
|
||||
+ " PRIMARY KEY(`sess_id`),"//
|
||||
+ " INDEX `changed_index` (`changed`)"//
|
||||
+ ") /*!40000 ENGINE=INNODB */ /*!40101 CHARACTER SET utf8 COLLATE utf8_general_ci */ ";
|
||||
Assert.assertTrue(WallUtils.isValidateMySql(sql, config)); //
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user