Skip to content

Commit

Permalink
GH-77 Order by aggregated column (Resolve #77)
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed May 22, 2024
1 parent db8c451 commit c83b82f
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ open class SelectStatement(
this.offset = offset
}

fun orderBy(vararg columns: Pair<Column<*>, Order>): SelectStatement = also {
fun orderBy(vararg columns: Pair<Selectable, Order>): SelectStatement = also {
require(this.orderBy == null) { "Order by clause is already defined" }
this.orderBy = columns
.map { OrderBy(it.first, it.second) }
Expand All @@ -102,7 +102,10 @@ open class SelectStatement(
.filter { !groupByColumns.contains(it) }
.takeIf { it.isNotEmpty() }
?.let { nonAggregatedColumns ->
database.logger.log(Level.WARN, "Non-aggregated columns: $nonAggregatedColumns used with group by clause")
database.logger.log(
Level.WARN,
"Non-aggregated columns: $nonAggregatedColumns used with group by clause"
)
}
}

Expand Down Expand Up @@ -157,4 +160,7 @@ open class SelectStatement(
}
}

fun <R> toSet(mapper: (Row) -> R): Set<R> =
map(mapper).toSet()

}

0 comments on commit c83b82f

Please sign in to comment.