Commit e2a67926 authored by haocao's avatar haocao
Browse files

Refactor parsing test cases for AbstractBaseParseTest.

parent 2500a965
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -202,8 +202,12 @@ public abstract class AbstractBaseParseTest {
            selectStatement.getItems().addAll(selectItems);
        }
        if (null != assertObj.getLimit()) {
            if (null != assertObj.getLimit().getOffset() && null != assertObj.getLimit().getOffsetParameterIndex()) {
                selectStatement.setLimit(new Limit(
                        assertObj.getLimit().getOffset(), assertObj.getLimit().getRowCount(), assertObj.getLimit().getOffsetParameterIndex(), assertObj.getLimit().getRowCountParameterIndex()));
            } else {
                selectStatement.setLimit(new Limit(assertObj.getLimit().getRowCount(), assertObj.getLimit().getRowCountParameterIndex()));
            }
        }
        result[5] = selectStatement;
        return result;
@@ -218,7 +222,7 @@ public abstract class AbstractBaseParseTest {
        }
        assertFalse(groupByColumns.hasNext());
//        assertAggregationSelectItem(actual);
//        assertTrue(new ReflectionEquals(limit).matches(actual.getLimit()));
        assertTrue(new ReflectionEquals(limit).matches(actual.getLimit()));
    }
    
    private void assertOrderBy(final SQLStatement actual) {
+10 −10
Original line number Diff line number Diff line
@@ -8,16 +8,16 @@
            <group-by-column owner="o" name="state" alias="GROUP_BY_DERIVED_0" order-by-type="ASC" />
        </group-by-columns>
    </assert>
    <!---->
    <!--<assert id="assertSelectWithGroupBy" sql="SELECT o.state FROM order o GROUP BY o.state" expected-sql="SELECT o.state FROM [Token(order)] o GROUP BY o.state">-->
        <!--<tables>-->
            <!--<table name="order" alias="o" />-->
        <!--</tables>-->
        <!--<group-by-columns>-->
            <!--<group-by-column owner="o" name="state" order-by-type="ASC" />-->
        <!--</group-by-columns>-->
    <!--</assert>-->
    <!---->
    
    <assert id="assertSelectWithGroupBy" sql="SELECT o.state FROM order o GROUP BY o.state" expected-sql="SELECT o.state FROM [Token(order)] o GROUP BY o.state">
        <tables>
            <table name="order" alias="o" />
        </tables>
        <group-by-columns>
            <group-by-column owner="o" name="state" order-by-type="ASC" />
        </group-by-columns>
    </assert>
    
    <assert id="assertSelectWithGroupByAndOrderByAndDirectiveColumn" sql="SELECT o.order_id orderId FROM order o GROUP BY o.state ASC, o.order_id DESC" expected-sql="SELECT o.order_id orderId , o.state AS sharding_gen_1 , o.order_id AS sharding_gen_2 FROM [Token(order)] o GROUP BY o.state ASC, o.order_id DESC">
        <tables>
            <table name="order" alias="o" />
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
        <tables>
            <table name="order" alias="o" />
        </tables>
        <limit offset="0" row-count="5" offset-index="-1" row-count-index="-1" />
        <limit row-count="5" offset-index="-1" row-count-index="-1" />
    </assert>

    <assert id="assertSelectForLimitOffset" sql="SELECT * FROM order o LIMIT 5 OFFSET 4" expected-sql="SELECT * FROM [Token(order)] o LIMIT [limit_count(5)] OFFSET [limit_offset(4)]">