diff --git a/core/src/main/kotlin/ch/ergon/dope/resolvable/clause/ISelectClause.kt b/core/src/main/kotlin/ch/ergon/dope/resolvable/clause/ISelectClause.kt index 006290f2..ba374e5d 100644 --- a/core/src/main/kotlin/ch/ergon/dope/resolvable/clause/ISelectClause.kt +++ b/core/src/main/kotlin/ch/ergon/dope/resolvable/clause/ISelectClause.kt @@ -45,7 +45,8 @@ interface ISelectOrderByClause : ISelectLimitClause { } interface ISelectGroupByClause : ISelectOrderByClause { - fun orderBy(orderExpression: OrderExpression) = SelectOrderByClause(orderExpression, parentClause = this) + fun orderBy(orderExpression: OrderExpression, vararg additionalOrderExpressions: OrderExpression) = + SelectOrderByClause(orderExpression, *additionalOrderExpressions, parentClause = this) fun orderBy(expression: TypeExpression, orderByType: OrderByType? = null) = orderBy(OrderExpression(expression, orderByType)) } diff --git a/core/src/test/kotlin/ch/ergon/dope/resolvable/clause/OrderByClauseTest.kt b/core/src/test/kotlin/ch/ergon/dope/resolvable/clause/OrderByClauseTest.kt index 53d01d12..41c2df71 100644 --- a/core/src/test/kotlin/ch/ergon/dope/resolvable/clause/OrderByClauseTest.kt +++ b/core/src/test/kotlin/ch/ergon/dope/resolvable/clause/OrderByClauseTest.kt @@ -257,6 +257,18 @@ class OrderByClauseTest : ManagerDependentTest { assertEquals(expected.toDopeQuery(manager), actual.toDopeQuery(manager)) } + @Test + fun `should support order by function with multiple orderExpressions`() { + val parentClause = someSelectClause() + val orderExpression1 = OrderExpression(someStringField()) + val orderExpression2 = OrderExpression(someNumberField(), ASC) + val expected = SelectOrderByClause(orderExpression1, orderExpression2, parentClause = parentClause) + + val actual = parentClause.orderBy(orderExpression1, orderExpression2) + + assertEquals(expected.toDopeQuery(manager), actual.toDopeQuery(manager)) + } + @Test fun `should support order by function with then order by with orderExpression`() { val stringField = someStringField()