forked from alibaba/druid
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
优化any/some/all函数解析逻辑 alibaba#5891
- Loading branch information
Showing
2 changed files
with
83 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
55 changes: 55 additions & 0 deletions
55
core/src/test/java/com/alibaba/druid/bvt/sql/oracle/issues/Issue5891.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,55 @@ | ||
package com.alibaba.druid.bvt.sql.oracle.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/5891>Issue来源</a> | ||
* @see <a href="https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Comparison-Conditions.html">Comparison Conditions</a> | ||
*/ | ||
public class Issue5891 { | ||
|
||
@Test | ||
public void test_parse_any() { | ||
for (DbType dbType : new DbType[]{DbType.oracle}) { | ||
for (String sql : new String[]{ | ||
//"SELECT * FROM tbl_name WHERE col > ANY (1, 5, 10);", | ||
"SELECT * FROM tbl_name WHERE col > SOME (1, 5, 10);", | ||
"SELECT * FROM tbl_name WHERE col = ANY ('1', '5', '10');", | ||
"SELECT * FROM tbl_name WHERE col = SOME ('1', '5', '10');", | ||
|
||
"SELECT * FROM employees\n" | ||
+ " WHERE salary = ANY\n" | ||
+ " (SELECT salary \n" | ||
+ " FROM employees\n" | ||
+ " WHERE department_id = 30)\n" | ||
+ " ORDER BY employee_id;", | ||
"SELECT * FROM employees\n" | ||
+ " WHERE salary >= ALL\n" | ||
+ " (SELECT salary \n" | ||
+ " FROM employees\n" | ||
+ " WHERE department_id = 30)\n" | ||
+ " ORDER BY employee_id;", | ||
"SELECT * FROM employees\n" | ||
+ " WHERE salary >=\n" | ||
+ " ALL (1400, 3000)\n" | ||
+ " ORDER BY employee_id;", | ||
}) { | ||
SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType); | ||
List<SQLStatement> statementList = parser.parseStatementList(); | ||
assertEquals(1, statementList.size()); | ||
SQLParseAssertUtil.assertParseSql(sql, dbType); | ||
} | ||
} | ||
} | ||
} |