@@ -253,30 +253,82 @@ def generateGroupingAggregateColumns(Writer writer, int tupleNumber) {
253253 * Group elements from the source sequence by key and perform the given aggregations for elements in each group,
254254 * then store the results in a new [Map].
255255 *
256- * See [EntityGrouping.aggregateColumns] for more details.
256+ * The key for each group is provided by the [EntityGrouping.keySelector] function, and the generated SQL is like:
257+ * `select key, aggregation from source group by key`.
257258 *
258259 * @param aggregationSelector a function that accepts the source table and returns a tuple of aggregate expressions.
259260 * @return a [Map] associating the key of each group with the results of aggregations of the group elements.
260261 */
262+ @Deprecated(
263+ message = "This function will be removed in the future. Please use aggregateColumns { .. } instead.",
264+ replaceWith = ReplaceWith("aggregateColumns(aggregationSelector)")
265+ )
261266 public inline fun <E : Any, T : BaseTable<E>, K : Any, $typeParams > EntityGrouping<E, T, K>.aggregateColumns$tupleNumber (
262267 aggregationSelector: (T) -> Tuple$tupleNumber <$columnDeclarings >
263268 ): Map<K?, Tuple$tupleNumber <$resultTypes >> {
264- return aggregateColumns${ tupleNumber } To(LinkedHashMap(), aggregationSelector)
269+ return aggregateColumns( aggregationSelector)
265270 }
266271
267272 /**
268273 * Group elements from the source sequence by key and perform the given aggregations for elements in each group,
269274 * then store the results in the [destination] map.
270275 *
271- * See [EntityGrouping.aggregateColumnsTo] for more details.
276+ * The key for each group is provided by the [EntityGrouping.keySelector] function, and the generated SQL is like:
277+ * `select key, aggregation from source group by key`.
272278 *
273279 * @param destination a [MutableMap] used to store the results.
274280 * @param aggregationSelector a function that accepts the source table and returns a tuple of aggregate expressions.
275281 * @return the [destination] map associating the key of each group with the result of aggregations of the group elements.
276282 */
283+ @Deprecated(
284+ message = "This function will be removed in the future. Please use aggregateColumns(destination) { .. } instead.",
285+ replaceWith = ReplaceWith("aggregateColumns(destination, aggregationSelector)")
286+ )
277287 public inline fun <E : Any, T : BaseTable<E>, K : Any, $typeParams , M> EntityGrouping<E, T, K>.aggregateColumns${ tupleNumber} To(
278288 destination: M,
279289 aggregationSelector: (T) -> Tuple$tupleNumber <$columnDeclarings >
290+ ): M where M : MutableMap<in K?, in Tuple$tupleNumber <$resultTypes >> {
291+ return aggregateColumnsTo(destination, aggregationSelector)
292+ }
293+
294+ /**
295+ * Group elements from the source sequence by key and perform the given aggregations for elements in each group,
296+ * then store the results in a new [Map].
297+ *
298+ * The key for each group is provided by the [EntityGrouping.keySelector] function, and the generated SQL is like:
299+ * `select key, aggregation from source group by key`.
300+ *
301+ * @param aggregationSelector a function that accepts the source table and returns a tuple of aggregate expressions.
302+ * @return a [Map] associating the key of each group with the results of aggregations of the group elements.
303+ * @since 3.1.0
304+ */
305+ @JvmName("_aggregateColumns$tupleNumber ")
306+ @OptIn(ExperimentalTypeInference::class)
307+ @OverloadResolutionByLambdaReturnType
308+ public inline fun <E : Any, T : BaseTable<E>, K : Any, $typeParams > EntityGrouping<E, T, K>.aggregateColumns(
309+ aggregationSelector: (T) -> Tuple$tupleNumber <$columnDeclarings >
310+ ): Map<K?, Tuple$tupleNumber <$resultTypes >> {
311+ return aggregateColumnsTo(LinkedHashMap(), aggregationSelector)
312+ }
313+
314+ /**
315+ * Group elements from the source sequence by key and perform the given aggregations for elements in each group,
316+ * then store the results in the [destination] map.
317+ *
318+ * The key for each group is provided by the [EntityGrouping.keySelector] function, and the generated SQL is like:
319+ * `select key, aggregation from source group by key`.
320+ *
321+ * @param destination a [MutableMap] used to store the results.
322+ * @param aggregationSelector a function that accepts the source table and returns a tuple of aggregate expressions.
323+ * @return the [destination] map associating the key of each group with the result of aggregations of the group elements.
324+ * @since 3.1.0
325+ */
326+ @JvmName("_aggregateColumns${ tupleNumber} To")
327+ @OptIn(ExperimentalTypeInference::class)
328+ @OverloadResolutionByLambdaReturnType
329+ public inline fun <E : Any, T : BaseTable<E>, K : Any, $typeParams , M> EntityGrouping<E, T, K>.aggregateColumnsTo(
330+ destination: M,
331+ aggregationSelector: (T) -> Tuple$tupleNumber <$columnDeclarings >
280332 ): M where M : MutableMap<in K?, in Tuple$tupleNumber <$resultTypes >> {
281333 val keyColumn = keySelector(sequence.sourceTable)
282334 val ($variableNames ) = aggregationSelector(sequence.sourceTable)
@@ -288,7 +340,7 @@ def generateGroupingAggregateColumns(Writer writer, int tupleNumber) {
288340
289341 for (row in Query(sequence.database, expr)) {
290342 val key = keyColumn.sqlType.getResult(row, 1)
291- destination[key] = Tuple $t upleNumber ($resultExtractors )
343+ destination[key] = tupleOf ($resultExtractors )
292344 }
293345
294346 return destination
0 commit comments