Search in sources :

Example 21 with SelectStatement

use of io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement in project sharding-jdbc by shardingjdbc.

the class LimitDecoratorMergedResultTest method setUp.

@Before
public void setUp() throws SQLException {
    ResultSet resultSet = mock(ResultSet.class);
    ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
    when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
    List<ResultSet> resultSets = Lists.newArrayList(resultSet, mock(ResultSet.class), mock(ResultSet.class), mock(ResultSet.class));
    for (ResultSet each : resultSets) {
        when(each.next()).thenReturn(true, true, false);
    }
    queryResults = new ArrayList<>(resultSets.size());
    for (ResultSet each : resultSets) {
        queryResults.add(new TestQueryResult(each));
    }
    selectStatement = new SelectStatement();
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) TestQueryResult(io.shardingjdbc.core.merger.fixture.TestQueryResult) SelectStatement(io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement) ResultSet(java.sql.ResultSet) Before(org.junit.Before)

Example 22 with SelectStatement

use of io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement in project sharding-jdbc by shardingjdbc.

the class RowNumberDecoratorMergedResultTest method setUp.

@Before
public void setUp() throws SQLException {
    ResultSet resultSet = mock(ResultSet.class);
    ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
    when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
    List<ResultSet> resultSets = Lists.newArrayList(resultSet, mock(ResultSet.class), mock(ResultSet.class), mock(ResultSet.class));
    for (ResultSet each : resultSets) {
        when(each.next()).thenReturn(true, true, false);
    }
    queryResults = new ArrayList<>(resultSets.size());
    for (ResultSet each : resultSets) {
        queryResults.add(new TestQueryResult(each));
    }
    selectStatement = new SelectStatement();
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) TestQueryResult(io.shardingjdbc.core.merger.fixture.TestQueryResult) SelectStatement(io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement) ResultSet(java.sql.ResultSet) Before(org.junit.Before)

Example 23 with SelectStatement

use of io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement in project sharding-jdbc by shardingjdbc.

the class TopAndRowNumberDecoratorMergedResultTest method setUp.

@Before
public void setUp() throws SQLException {
    ResultSet resultSet = mock(ResultSet.class);
    ResultSetMetaData resultSetMetaData = mock(ResultSetMetaData.class);
    when(resultSet.getMetaData()).thenReturn(resultSetMetaData);
    List<ResultSet> resultSets = Lists.newArrayList(resultSet, mock(ResultSet.class), mock(ResultSet.class), mock(ResultSet.class));
    for (ResultSet each : resultSets) {
        when(each.next()).thenReturn(true, true, false);
    }
    queryResults = new ArrayList<>(resultSets.size());
    for (ResultSet each : resultSets) {
        queryResults.add(new TestQueryResult(each));
    }
    selectStatement = new SelectStatement();
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) TestQueryResult(io.shardingjdbc.core.merger.fixture.TestQueryResult) SelectStatement(io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement) ResultSet(java.sql.ResultSet) Before(org.junit.Before)

Example 24 with SelectStatement

use of io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement in project sharding-jdbc by shardingjdbc.

the class SelectStatementTest method assertIsSameGroupByAndOrderByItemsWhenDifferent.

@Test
public void assertIsSameGroupByAndOrderByItemsWhenDifferent() {
    SelectStatement actual = new SelectStatement();
    actual.getOrderByItems().add(new OrderItem("order_col", OrderDirection.ASC, OrderDirection.ASC, Optional.<String>absent()));
    actual.getGroupByItems().add(new OrderItem("group_col", OrderDirection.ASC, OrderDirection.ASC, Optional.<String>absent()));
    assertFalse(actual.isSameGroupByAndOrderByItems());
}
Also used : SelectStatement(io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement) OrderItem(io.shardingjdbc.core.parsing.parser.context.OrderItem) Test(org.junit.Test)

Example 25 with SelectStatement

use of io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement in project sharding-jdbc by shardingjdbc.

the class SelectStatementTest method assertIsSameGroupByAndOrderByItemsWhenSame.

@Test
public void assertIsSameGroupByAndOrderByItemsWhenSame() {
    SelectStatement actual = new SelectStatement();
    actual.getOrderByItems().add(new OrderItem("col", OrderDirection.ASC, OrderDirection.ASC, Optional.<String>absent()));
    actual.getGroupByItems().add(new OrderItem("col", OrderDirection.ASC, OrderDirection.ASC, Optional.<String>absent()));
    assertTrue(actual.isSameGroupByAndOrderByItems());
}
Also used : SelectStatement(io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement) OrderItem(io.shardingjdbc.core.parsing.parser.context.OrderItem) Test(org.junit.Test)

Aggregations

SelectStatement (io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement)25 OrderItem (io.shardingjdbc.core.parsing.parser.context.OrderItem)12 ResultSet (java.sql.ResultSet)10 Before (org.junit.Before)9 Test (org.junit.Test)9 TestQueryResult (io.shardingjdbc.core.merger.fixture.TestQueryResult)8 MemoryQueryResultRow (io.shardingjdbc.core.merger.dql.common.MemoryQueryResultRow)6 ResultSetMetaData (java.sql.ResultSetMetaData)6 DALStatement (io.shardingjdbc.core.parsing.parser.sql.dal.DALStatement)3 GeneratedKeysResultSet (io.shardingjdbc.core.jdbc.core.resultset.GeneratedKeysResultSet)2 ShardingResultSet (io.shardingjdbc.core.jdbc.core.resultset.ShardingResultSet)2 JDBCQueryResult (io.shardingjdbc.core.merger.JDBCQueryResult)2 MergeEngine (io.shardingjdbc.core.merger.MergeEngine)2 QueryResult (io.shardingjdbc.core.merger.QueryResult)2 AggregationSelectItem (io.shardingjdbc.core.parsing.parser.context.selectitem.AggregationSelectItem)2 InsertStatement (io.shardingjdbc.core.parsing.parser.sql.dml.insert.InsertStatement)2 DQLStatement (io.shardingjdbc.core.parsing.parser.sql.dql.DQLStatement)2 ArrayList (java.util.ArrayList)2 DQLMergeEngine (io.shardingjdbc.core.merger.dql.DQLMergeEngine)1 DefaultKeyword (io.shardingjdbc.core.parsing.lexer.token.DefaultKeyword)1