use of io.shardingjdbc.core.parsing.parser.context.OrderItem in project sharding-jdbc by shardingjdbc.
the class DQLMergeEngineTest method assertBuildOrderByStreamMergedResultWithSQLServerLimit.
@Test
public void assertBuildOrderByStreamMergedResultWithSQLServerLimit() throws SQLException {
selectStatement.setLimit(new Limit(DatabaseType.SQLServer));
selectStatement.getOrderByItems().add(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC));
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
MergedResult actual = mergeEngine.merge();
assertThat(actual, instanceOf(TopAndRowNumberDecoratorMergedResult.class));
assertThat(((TopAndRowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(OrderByStreamMergedResult.class));
}
use of io.shardingjdbc.core.parsing.parser.context.OrderItem in project sharding-jdbc by shardingjdbc.
the class DQLMergeEngineTest method assertBuildOrderByStreamMergedResult.
@Test
public void assertBuildOrderByStreamMergedResult() throws SQLException {
selectStatement.getOrderByItems().add(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC));
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
assertThat(mergeEngine.merge(), instanceOf(OrderByStreamMergedResult.class));
}
use of io.shardingjdbc.core.parsing.parser.context.OrderItem in project sharding-jdbc by shardingjdbc.
the class DQLMergeEngineTest method assertBuildGroupByMemoryMergedResultWithOracleLimit.
@Test
public void assertBuildGroupByMemoryMergedResultWithOracleLimit() throws SQLException {
selectStatement.setLimit(new Limit(DatabaseType.Oracle));
selectStatement.getGroupByItems().add(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC));
selectStatement.getOrderByItems().add(new OrderItem(2, OrderDirection.DESC, OrderDirection.ASC));
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
MergedResult actual = mergeEngine.merge();
assertThat(actual, instanceOf(RowNumberDecoratorMergedResult.class));
assertThat(((RowNumberDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByMemoryMergedResult.class));
}
use of io.shardingjdbc.core.parsing.parser.context.OrderItem in project sharding-jdbc by shardingjdbc.
the class DQLMergeEngineTest method assertBuildGroupByMemoryMergedResultWithMySQLLimit.
@Test
public void assertBuildGroupByMemoryMergedResultWithMySQLLimit() throws SQLException {
selectStatement.setLimit(new Limit(DatabaseType.MySQL));
selectStatement.getGroupByItems().add(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC));
mergeEngine = new DQLMergeEngine(queryResults, selectStatement);
MergedResult actual = mergeEngine.merge();
assertThat(actual, instanceOf(LimitDecoratorMergedResult.class));
assertThat(((LimitDecoratorMergedResult) actual).getMergedResult(), instanceOf(GroupByMemoryMergedResult.class));
}
use of io.shardingjdbc.core.parsing.parser.context.OrderItem in project sharding-jdbc by shardingjdbc.
the class GroupByRowComparatorTest method assertCompareToForAscWithOrderByItems.
@Test
public void assertCompareToForAscWithOrderByItems() throws SQLException {
MemoryQueryResultRow o1 = new MemoryQueryResultRow(mockQueryResult("1", "2"));
MemoryQueryResultRow o2 = new MemoryQueryResultRow(mockQueryResult("3", "4"));
SelectStatement selectStatement = new SelectStatement();
selectStatement.getOrderByItems().addAll(Arrays.asList(new OrderItem(1, OrderDirection.ASC, OrderDirection.ASC), new OrderItem(2, OrderDirection.ASC, OrderDirection.ASC)));
selectStatement.getGroupByItems().addAll(Arrays.asList(new OrderItem(1, OrderDirection.DESC, OrderDirection.ASC), new OrderItem(2, OrderDirection.DESC, OrderDirection.ASC)));
GroupByRowComparator groupByRowComparator = new GroupByRowComparator(selectStatement);
assertTrue(groupByRowComparator.compare(o1, o2) < 0);
}
Aggregations