Search in sources :

Example 16 with MergedResult

use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.

the class RowNumberDecoratorMergedResultTest method assertNextWithoutOffsetWithoutRowCount.

@Test
public void assertNextWithoutOffsetWithoutRowCount() throws SQLException {
    Limit limit = new Limit(DatabaseType.Oracle);
    selectStatement.setLimit(limit);
    mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
    MergedResult actual = mergeEngine.merge();
    for (int i = 0; i < 8; i++) {
        assertTrue(actual.next());
    }
    assertFalse(actual.next());
}
Also used : MergedResult(io.shardingjdbc.core.merger.MergedResult) DQLMergeEngine(io.shardingjdbc.core.merger.dql.DQLMergeEngine) Limit(io.shardingjdbc.core.parsing.parser.context.limit.Limit) Test(org.junit.Test)

Example 17 with MergedResult

use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.

the class RowNumberDecoratorMergedResultTest method assertNextForRowCountBoundOpenedTrue.

@Test
public void assertNextForRowCountBoundOpenedTrue() throws SQLException {
    Limit limit = new Limit(DatabaseType.Oracle);
    limit.setOffset(new LimitValue(2, -1, true));
    limit.setRowCount(new LimitValue(4, -1, true));
    selectStatement.setLimit(limit);
    mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
    MergedResult actual = mergeEngine.merge();
    assertTrue(actual.next());
    assertTrue(actual.next());
    assertTrue(actual.next());
    assertFalse(actual.next());
}
Also used : MergedResult(io.shardingjdbc.core.merger.MergedResult) DQLMergeEngine(io.shardingjdbc.core.merger.dql.DQLMergeEngine) Limit(io.shardingjdbc.core.parsing.parser.context.limit.Limit) LimitValue(io.shardingjdbc.core.parsing.parser.context.limit.LimitValue) Test(org.junit.Test)

Example 18 with MergedResult

use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.

the class TopAndRowNumberDecoratorMergedResultTest method assertNextWithOffsetBoundOpenedTrue.

@Test
public void assertNextWithOffsetBoundOpenedTrue() throws SQLException {
    Limit limit = new Limit(DatabaseType.SQLServer);
    limit.setOffset(new LimitValue(2, -1, true));
    limit.setRowCount(new LimitValue(4, -1, false));
    selectStatement.setLimit(limit);
    mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
    MergedResult actual = mergeEngine.merge();
    assertTrue(actual.next());
    assertTrue(actual.next());
    assertTrue(actual.next());
    assertFalse(actual.next());
}
Also used : MergedResult(io.shardingjdbc.core.merger.MergedResult) DQLMergeEngine(io.shardingjdbc.core.merger.dql.DQLMergeEngine) Limit(io.shardingjdbc.core.parsing.parser.context.limit.Limit) LimitValue(io.shardingjdbc.core.parsing.parser.context.limit.LimitValue) Test(org.junit.Test)

Example 19 with MergedResult

use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.

the class TopAndRowNumberDecoratorMergedResultTest method assertNextWithoutOffsetWithRowCount.

@Test
public void assertNextWithoutOffsetWithRowCount() throws SQLException {
    Limit limit = new Limit(DatabaseType.SQLServer);
    limit.setRowCount(new LimitValue(5, -1, false));
    selectStatement.setLimit(limit);
    mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
    MergedResult actual = mergeEngine.merge();
    for (int i = 0; i < 5; i++) {
        assertTrue(actual.next());
    }
    assertFalse(actual.next());
}
Also used : MergedResult(io.shardingjdbc.core.merger.MergedResult) DQLMergeEngine(io.shardingjdbc.core.merger.dql.DQLMergeEngine) Limit(io.shardingjdbc.core.parsing.parser.context.limit.Limit) LimitValue(io.shardingjdbc.core.parsing.parser.context.limit.LimitValue) Test(org.junit.Test)

Example 20 with MergedResult

use of io.shardingjdbc.core.merger.MergedResult in project sharding-jdbc by shardingjdbc.

the class TopAndRowNumberDecoratorMergedResultTest method assertNextWithOffsetWithoutRowCount.

@Test
public void assertNextWithOffsetWithoutRowCount() throws SQLException {
    Limit limit = new Limit(DatabaseType.SQLServer);
    limit.setOffset(new LimitValue(2, -1, true));
    selectStatement.setLimit(limit);
    mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
    MergedResult actual = mergeEngine.merge();
    for (int i = 0; i < 7; i++) {
        assertTrue(actual.next());
    }
    assertFalse(actual.next());
}
Also used : MergedResult(io.shardingjdbc.core.merger.MergedResult) DQLMergeEngine(io.shardingjdbc.core.merger.dql.DQLMergeEngine) Limit(io.shardingjdbc.core.parsing.parser.context.limit.Limit) LimitValue(io.shardingjdbc.core.parsing.parser.context.limit.LimitValue) Test(org.junit.Test)

Aggregations

MergedResult (io.shardingjdbc.core.merger.MergedResult)42 Test (org.junit.Test)41 Limit (io.shardingjdbc.core.parsing.parser.context.limit.Limit)27 DQLMergeEngine (io.shardingjdbc.core.merger.dql.DQLMergeEngine)26 GroupByMemoryMergedResult (io.shardingjdbc.core.merger.dql.groupby.GroupByMemoryMergedResult)15 GroupByStreamMergedResult (io.shardingjdbc.core.merger.dql.groupby.GroupByStreamMergedResult)15 IteratorStreamMergedResult (io.shardingjdbc.core.merger.dql.iterator.IteratorStreamMergedResult)15 OrderByStreamMergedResult (io.shardingjdbc.core.merger.dql.orderby.OrderByStreamMergedResult)15 LimitDecoratorMergedResult (io.shardingjdbc.core.merger.dql.pagination.LimitDecoratorMergedResult)15 RowNumberDecoratorMergedResult (io.shardingjdbc.core.merger.dql.pagination.RowNumberDecoratorMergedResult)15 TopAndRowNumberDecoratorMergedResult (io.shardingjdbc.core.merger.dql.pagination.TopAndRowNumberDecoratorMergedResult)15 LimitValue (io.shardingjdbc.core.parsing.parser.context.limit.LimitValue)11 OrderItem (io.shardingjdbc.core.parsing.parser.context.OrderItem)9 AggregationSelectItem (io.shardingjdbc.core.parsing.parser.context.selectitem.AggregationSelectItem)3 BigDecimal (java.math.BigDecimal)3 QueryResult (io.shardingjdbc.core.merger.QueryResult)2 TestQueryResult (io.shardingjdbc.core.merger.fixture.TestQueryResult)2 MySQLPacketQueryResult (io.shardingjdbc.proxy.backend.mysql.MySQLPacketQueryResult)1 DatabaseProtocolPacket (io.shardingjdbc.proxy.transport.common.packet.DatabaseProtocolPacket)1 ErrPacket (io.shardingjdbc.proxy.transport.mysql.packet.generic.ErrPacket)1