-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
进一步优化括号的输出逻辑 #3775
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
core/src/test/java/com/alibaba/druid/bvt/sql/mysql/issues/Issue3775.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.alibaba.druid.bvt.sql.mysql.issues; | ||
|
||
import java.util.List; | ||
|
||
import com.alibaba.druid.DbType; | ||
import com.alibaba.druid.sql.SQLParseAssertUtil; | ||
import com.alibaba.druid.sql.ast.SQLStatement; | ||
import com.alibaba.druid.sql.parser.SQLParserUtils; | ||
import com.alibaba.druid.sql.parser.SQLStatementParser; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author lizongbo | ||
* @see <a href="https://github.com/alibaba/druid/issues/3775>Issue来源</a> | ||
*/ | ||
public class Issue3775 { | ||
@Test | ||
public void test_parse_parentheses() { | ||
for (DbType dbType : new DbType[]{DbType.mysql}) { | ||
for (String sql : new String[]{ | ||
"SELECT ((700055789 % (66666*4444))%8888);", | ||
}) { | ||
SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType); | ||
List<SQLStatement> statementList = parser.parseStatementList(); | ||
System.out.println(statementList); | ||
assertEquals(1, statementList.size()); | ||
assertEquals("SELECT ((700055789 % (66666 * 4444)) % 8888);", statementList.get(0).toString()); | ||
SQLParseAssertUtil.assertParseSql(sql, dbType); | ||
} | ||
} | ||
} | ||
} |