All Downloads are FREE. Search and download functionalities are using the official Maven repository.

calasql-core_3.0.1.5.source-code.Aggregatable.scala Maven / Gradle / Ivy

package scalasql.core

/**
 * Something that supports aggregate operations. Most commonly a [[Select]], but
 * also could be a [[Aggregatable.Proxy]]
 */
trait Aggregatable[Q] extends WithSqlExpr[Q] {
  def aggregateExpr[V: TypeMapper](f: Q => Context => SqlStr)(
      implicit qr: Queryable.Row[Expr[V], V]
  ): Expr[V]
}

object Aggregatable {

  /**
   * A reference that aggregations for usage within [[Select.aggregate]], to allow
   * the caller to perform multiple aggregations within a single query.
   */
  class Proxy[Q](val expr: Q) extends Aggregatable[Q] {
    def aggregateExpr[V: TypeMapper](f: Q => Context => SqlStr)(
        implicit qr: Queryable.Row[Expr[V], V]
    ): Expr[V] = { Expr[V] { implicit c => f(expr)(c) } }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy