Skip to content

Commit aaab9c3

Browse files
committed
Failing test for order by collections
1 parent eda471c commit aaab9c3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/test/java/org/mybatis/dynamic/sql/select/SelectStatementTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static org.mybatis.dynamic.sql.SqlBuilder.*;
2222

2323
import java.sql.JDBCType;
24+
import java.util.ArrayList;
2425
import java.util.Collection;
2526
import java.util.Collections;
2627
import java.util.Date;
@@ -29,6 +30,7 @@
2930

3031
import org.junit.jupiter.api.Test;
3132
import org.mybatis.dynamic.sql.Callback;
33+
import org.mybatis.dynamic.sql.SortSpecification;
3234
import org.mybatis.dynamic.sql.SqlColumn;
3335
import org.mybatis.dynamic.sql.SqlTable;
3436
import org.mybatis.dynamic.sql.render.RenderingStrategies;
@@ -176,6 +178,27 @@ void testOrderByMultipleColumns() {
176178
);
177179
}
178180

181+
@Test
182+
void testOrderByMultipleColumnsWithCollection() {
183+
Collection<SortSpecification> orderByColumns = new ArrayList<>();
184+
orderByColumns.add(column2.descending());
185+
orderByColumns.add(column1);
186+
187+
SelectStatementProvider selectStatement = select(column1.as("A_COLUMN1"), column2)
188+
.from(table, "a")
189+
.orderBy(orderByColumns)
190+
.build()
191+
.render(RenderingStrategies.MYBATIS3);
192+
193+
String expectedFullStatement = "select a.column1 as A_COLUMN1, a.column2 "
194+
+ "from foo a "
195+
+ "order by column2 DESC, column1";
196+
197+
Map<String, Object> parameters = selectStatement.getParameters();
198+
199+
assertThat(selectStatement.getSelectStatement()).isEqualTo(expectedFullStatement);
200+
}
201+
179202
@Test
180203
void testDistinct() {
181204
Date d = new Date();

0 commit comments

Comments
 (0)