improve wall filter

This commit is contained in:
wenshao
2013-04-12 15:39:54 +08:00
parent 60875af0e4
commit e2993be3f7
2 changed files with 15 additions and 1 deletions
@@ -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);
}
}