diff --git a/src/test/java/com/alibaba/druid/bvt/sql/mysql/OceanbaseHintTest_multiget.java b/src/test/java/com/alibaba/druid/bvt/sql/mysql/OceanbaseHintTest_multiget.java new file mode 100644 index 0000000000..47d9ae9f14 --- /dev/null +++ b/src/test/java/com/alibaba/druid/bvt/sql/mysql/OceanbaseHintTest_multiget.java @@ -0,0 +1,60 @@ +/* + * Copyright 1999-2101 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.alibaba.druid.bvt.sql.mysql; + +import java.util.List; + +import org.junit.Assert; + +import com.alibaba.druid.sql.MysqlTest; +import com.alibaba.druid.sql.SQLUtils; +import com.alibaba.druid.sql.ast.SQLStatement; +import com.alibaba.druid.sql.dialect.mysql.parser.MySqlStatementParser; +import com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor; + +public class OceanbaseHintTest_multiget extends MysqlTest { + + public void test_0() throws Exception { + String sql = "SELECT * FROM t1 WHERE (c1, c2, c3) IN ((1,2,3), (4,5,6))"; + + MySqlStatementParser parser = new MySqlStatementParser(sql); + List stmtList = parser.parseStatementList(); + SQLStatement stmt = stmtList.get(0); + + String result = SQLUtils.toMySqlString(stmt); + Assert.assertEquals("SELECT *" + + "\nFROM t1" + + "\nWHERE (c1, c2, c3) IN ((1, 2, 3), (4, 5, 6))", result); + print(stmtList); + + Assert.assertEquals(1, stmtList.size()); + + MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor(); + stmt.accept(visitor); + + System.out.println("Tables : " + visitor.getTables()); + System.out.println("fields : " + visitor.getColumns()); + System.out.println("coditions : " + visitor.getConditions()); + System.out.println("orderBy : " + visitor.getOrderByColumns()); + + Assert.assertEquals(1, visitor.getTables().size()); + Assert.assertEquals(4, visitor.getColumns().size()); + Assert.assertEquals(0, visitor.getConditions().size()); + +// Assert.assertTrue(visitor.getTables().containsKey(new TableStat.Name("t_basic_store"))); + + } +} diff --git a/src/test/resources/bvt/parser/mysql-5.txt b/src/test/resources/bvt/parser/mysql-5.txt index 5aea645438..eaec84c2ef 100644 --- a/src/test/resources/bvt/parser/mysql-5.txt +++ b/src/test/resources/bvt/parser/mysql-5.txt @@ -8,7 +8,7 @@ ORDER BY e.word_alias,a.createtime DESC --------------------------- -SELECT COUNT(*) +SELECT /*+ use_hash(a b e) index(e)*/ COUNT(*) FROM q_matchrelation a, q_offerdetail b, q_keyword e, Q_ADCREATIVE f WHERE a.offerid = b.offerid AND a.keywordid = e.keywordid