提交 e3e96870 编写于 作者: H haocao

Refactor parser and integrate test cases from to do xml 13th.

上级 75961108
......@@ -13,7 +13,6 @@ import javax.xml.bind.JAXBException;
import java.io.File;
import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
......@@ -73,13 +72,13 @@ public final class SQLStatementHelper {
}
public static String getSql(final String sqlId) {
return STATEMENT_MAP.get(sqlId).getSql();
checkSqlId(sqlId);
SQLStatement statement = STATEMENT_MAP.get(sqlId);
return statement.getSql();
}
public static Set<DatabaseType> getTypes(final String sqlId) {
if (null == sqlId || !STATEMENT_MAP.containsKey(sqlId)) {
return Collections.emptySet();
}
checkSqlId(sqlId);
SQLStatement statement = STATEMENT_MAP.get(sqlId);
if (null == statement.getTypes()) {
return Sets.newHashSet(DatabaseType.values());
......@@ -90,4 +89,10 @@ public final class SQLStatementHelper {
}
return result;
}
private static void checkSqlId(final String sqlId) {
if (null == sqlId || !STATEMENT_MAP.containsKey(sqlId)) {
throw new RuntimeException("Can't find sql of id:" + sqlId);
}
}
}
......@@ -15,12 +15,12 @@
<table name="t_order" />
</tables>
</assert>
<assert id="assertCreateTempGlobalTable">
<assert id="assertCreateGlobalTemporaryTable">
<tables>
<table name="t_order" />
</tables>
</assert>
<assert id="assertCreateTempLocalTemporaryTable">
<assert id="assertCreateLocalTempTable">
<tables>
<table name="t_order" />
</tables>
......
......@@ -46,11 +46,10 @@
</order-by-columns>
<limit offset="5" offset-index="4" row-count="3" row-count-index="5" />
</assert>
<assert id="assertSelectPaginationWithGroupByAndOrderByInSQLServer" parameters="3,1,2,9,10,6">
<assert id="assertSelectPaginationWithTopAndGroupByAndOrderBy" parameters="3,1,2,9,10,6">
<tables>
<table name="t_order" alias="o" />
<table name="t_order_item" alias="i" />
<table name="row_" />
</tables>
<conditions>
<condition column-name="user_id" table-name="t_order" operator="IN">
......@@ -70,11 +69,10 @@
</order-by-columns>
<limit offset="6" offset-index="5" row-count-index="0" row-count="3" />
</assert>
<assert id="assertSelectPaginationWithDiffGroupByAndOrderByInSQLServer" parameters="3,1,2,9,10,6">
<assert id="assertSelectPaginationWithTopAndGroupByAndOrderByAndParentheses" parameters="3,1,2,9,10,6">
<tables>
<table name="t_order" alias="o" />
<table name="t_order_item" alias="i" />
<table name="row_" />
</tables>
<conditions>
<condition column-name="user_id" table-name="t_order" operator="IN">
......@@ -87,18 +85,17 @@
</condition>
</conditions>
<group-by-columns>
<group-by-column name="user_id" alias="GROUP_BY_DERIVED_0" owner="i" order-by-type="ASC" />
<group-by-column name="item_id" owner="i" order-by-type="ASC" />
</group-by-columns>
<order-by-columns>
<order-by-column name="item_id" owner="i" order-by-type="DESC" />
</order-by-columns>
<limit offset="6" offset-index="5" row-count-index="0" row-count="3" />
</assert>
<assert id="assertSelectPaginationWithGroupByAndOrderByAndParenthesesInSQLServer" parameters="3,1,2,9,10,6">
<assert id="assertSelectPaginationWithTopAndDiffGroupByAndOrderBy" parameters="3,1,2,9,10,6">
<tables>
<table name="t_order" alias="o" />
<table name="t_order_item" alias="i" />
<table name="row_" />
</tables>
<conditions>
<condition column-name="user_id" table-name="t_order" operator="IN">
......@@ -111,18 +108,17 @@
</condition>
</conditions>
<group-by-columns>
<group-by-column name="item_id" owner="i" order-by-type="ASC" />
<group-by-column name="user_id" alias="GROUP_BY_DERIVED_0" owner="i" order-by-type="ASC" />
</group-by-columns>
<order-by-columns>
<order-by-column name="item_id" owner="i" order-by-type="DESC" />
</order-by-columns>
<limit offset="6" offset-index="5" row-count-index="0" row-count="3" />
</assert>
<assert id="assertSelectPaginationWithDiffGroupByAndOrderByAndParenthesesInSQLServer" parameters="3,1,2,9,10,6">
<assert id="assertSelectPaginationWithTopAndDiffGroupByAndOrderByAndParentheses" parameters="3,1,2,9,10,6">
<tables>
<table name="t_order" alias="o" />
<table name="t_order_item" alias="i" />
<table name="row_" />
</tables>
<conditions>
<condition column-name="user_id" table-name="t_order" operator="IN">
......@@ -142,12 +138,10 @@
</order-by-columns>
<limit offset="6" offset-index="5" row-count-index="0" row-count="3" />
</assert>
<assert id="assertSelectPaginationWithGroupByAndOrderByInOracle" parameters="1,2,9,10,5,3">
<assert id="assertSelectPaginationWithRowNumberAndGroupByAndOrderBy" parameters="1,2,9,10,5,3">
<tables>
<table name="t_order" alias="order0_" />
<table name="t_order_item" alias="i" />
<table name="row_" />
<table name="t" />
</tables>
<conditions>
<condition column-name="user_id" table-name="t_order" operator="IN">
......@@ -167,12 +161,10 @@
</order-by-columns>
<limit offset="3" offset-index="5" row-count-index="4" row-count="5" />
</assert>
<assert id="assertSelectPaginationWithDiffGroupByAndOrderByInOracle" parameters="1,2,9,10,5,3">
<assert id="assertSelectPaginationWithRowNumberAndDiffGroupByAndOrderBy" parameters="1,2,9,10,5,3">
<tables>
<table name="t_order" alias="order0_" />
<table name="t_order_item" alias="i" />
<table name="row_" />
<table name="t" />
</tables>
<conditions>
<condition column-name="user_id" table-name="t_order" operator="IN">
......
......@@ -4,6 +4,6 @@
<sql id="assertCreateTableIfNotExist" value="CREATE TABLE IF NOT EXISTS t_order(id int)" type="MySQL,PostgreSQL" />
<sql id="assertCreateTemporaryTable" value="CREATE TEMPORARY TABLE IF NOT EXISTS t_order(id int)" type="MySQL,PostgreSQL" />
<sql id="assertCreateGlobalTemporaryTable" value="CREATE GLOBAL TEMPORARY TABLE t_order(id int)" type="Oracle,PostgreSQL" />
<sql id="assertCreateTempLocalTempTable" value="CREATE LOCAL TEMP TABLE t_order(id int)" type="PostgreSQL" />
<sql id="assertCreateLocalTempTable" value="CREATE LOCAL TEMP TABLE t_order(id int)" type="PostgreSQL" />
<sql id="assertCreateUnloggedTable" value="CREATE UNLOGGED TABLE t_order(id int)" type="PostgreSQL" />
</sqls>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册