|
21 | 21 | import static org.mybatis.dynamic.sql.SqlBuilder.*;
|
22 | 22 |
|
23 | 23 | import java.sql.JDBCType;
|
| 24 | +import java.util.ArrayList; |
24 | 25 | import java.util.Collection;
|
25 | 26 | import java.util.Collections;
|
26 | 27 | import java.util.Date;
|
|
29 | 30 |
|
30 | 31 | import org.junit.jupiter.api.Test;
|
31 | 32 | import org.mybatis.dynamic.sql.Callback;
|
| 33 | +import org.mybatis.dynamic.sql.SortSpecification; |
32 | 34 | import org.mybatis.dynamic.sql.SqlColumn;
|
33 | 35 | import org.mybatis.dynamic.sql.SqlTable;
|
34 | 36 | import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
@@ -176,6 +178,27 @@ void testOrderByMultipleColumns() {
|
176 | 178 | );
|
177 | 179 | }
|
178 | 180 |
|
| 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 | + |
179 | 202 | @Test
|
180 | 203 | void testDistinct() {
|
181 | 204 | Date d = new Date();
|
|
0 commit comments