Search in sources :

Example 16 with LimitValue

use of io.shardingjdbc.core.parsing.parser.context.limit.LimitValue 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 17 with LimitValue

use of io.shardingjdbc.core.parsing.parser.context.limit.LimitValue 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 18 with LimitValue

use of io.shardingjdbc.core.parsing.parser.context.limit.LimitValue 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 19 with LimitValue

use of io.shardingjdbc.core.parsing.parser.context.limit.LimitValue 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)

Example 20 with LimitValue

use of io.shardingjdbc.core.parsing.parser.context.limit.LimitValue in project sharding-jdbc by shardingjdbc.

the class TopAndRowNumberDecoratorMergedResultTest method assertNextForSkipAll.

@Test
public void assertNextForSkipAll() throws SQLException {
    Limit limit = new Limit(DatabaseType.SQLServer);
    limit.setOffset(new LimitValue(Integer.MAX_VALUE, -1, true));
    selectStatement.setLimit(limit);
    mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
    MergedResult actual = mergeEngine.merge();
    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

LimitValue (io.shardingjdbc.core.parsing.parser.context.limit.LimitValue)29 Limit (io.shardingjdbc.core.parsing.parser.context.limit.Limit)27 Test (org.junit.Test)20 RowCountToken (io.shardingjdbc.core.parsing.parser.token.RowCountToken)15 OffsetToken (io.shardingjdbc.core.parsing.parser.token.OffsetToken)13 MergedResult (io.shardingjdbc.core.merger.MergedResult)11 DQLMergeEngine (io.shardingjdbc.core.merger.dql.DQLMergeEngine)11 TableToken (io.shardingjdbc.core.parsing.parser.token.TableToken)9 SQLParsingException (io.shardingjdbc.core.parsing.parser.exception.SQLParsingException)7 OrderItem (io.shardingjdbc.core.parsing.parser.context.OrderItem)3 SQLExpression (io.shardingjdbc.core.parsing.parser.expression.SQLExpression)3 SQLNumberExpression (io.shardingjdbc.core.parsing.parser.expression.SQLNumberExpression)3 SQLPlaceholderExpression (io.shardingjdbc.core.parsing.parser.expression.SQLPlaceholderExpression)3