mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve wall filter
This commit is contained in:
@@ -67,6 +67,11 @@ public class MySqlLexer extends Lexer {
|
||||
throw new ParserException("illegal stat");
|
||||
}
|
||||
|
||||
if (charAt(pos + 1) == '{') {
|
||||
scanVariable();
|
||||
return;
|
||||
}
|
||||
|
||||
Token lastToken = this.token;
|
||||
|
||||
scanChar();
|
||||
@@ -420,7 +425,7 @@ public class MySqlLexer extends Lexer {
|
||||
}
|
||||
|
||||
if (isHint) {
|
||||
stringVal = subString(mark + startHintSp, (bufPos - startHintSp) - 1);
|
||||
stringVal = subString(mark + startHintSp, (bufPos - startHintSp) - 2);
|
||||
token = Token.HINT;
|
||||
} else {
|
||||
stringVal = subString(mark, bufPos);
|
||||
|
||||
@@ -43,4 +43,13 @@ public class HintsTest extends TestCase {
|
||||
String output = SQLUtils.toMySqlString(stmt);
|
||||
Assert.assertEquals("SELECT /*! STRAIGHT_JOIN */ col1\nFROM table1, table2", output);
|
||||
}
|
||||
|
||||
public void test_hints_none() throws Exception {
|
||||
String sql = "SELECT /* STRAIGHT_JOIN */ col1 FROM table1,table2";
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
SQLStatement stmt = parser.parseStatementList().get(0);
|
||||
parser.match(Token.EOF);
|
||||
String output = SQLUtils.toMySqlString(stmt);
|
||||
Assert.assertEquals("SELECT col1\nFROM table1, table2", output);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user