Skip to content

fix: remove uneeded Numeric constraint #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions scalasql/operations/src/AggOps.scala
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ class AggOps[T](v: Aggregatable[T])(implicit qr: Queryable.Row[T, ?], dialect: D
def size: Expr[Int] = v.aggregateExpr(_ => _ => sql"COUNT(1)")

/** Computes the sum of column values */
def sumBy[V: Numeric: TypeMapper](f: T => Expr[V])(
def sumBy[V: TypeMapper](f: T => Expr[V])(
implicit qr: Queryable.Row[Expr[V], V]
): Expr[V] = v.aggregateExpr(expr => implicit ctx => sql"SUM(${f(expr)})")

@@ -22,32 +22,32 @@ class AggOps[T](v: Aggregatable[T])(implicit qr: Queryable.Row[T, ?], dialect: D
): Expr[V] = v.aggregateExpr(expr => implicit ctx => sql"MIN(${f(expr)})")

/** Finds the maximum value in a column */
def maxBy[V: Numeric: TypeMapper](f: T => Expr[V])(
def maxBy[V: TypeMapper](f: T => Expr[V])(
implicit qr: Queryable.Row[Expr[V], V]
): Expr[V] = v.aggregateExpr(expr => implicit ctx => sql"MAX(${f(expr)})")

/** Computes the average value of a column */
def avgBy[V: Numeric: TypeMapper](f: T => Expr[V])(
def avgBy[V: TypeMapper](f: T => Expr[V])(
implicit qr: Queryable.Row[Expr[V], V]
): Expr[V] = v.aggregateExpr(expr => implicit ctx => sql"AVG(${f(expr)})")

/** Computes the sum of column values */
def sumByOpt[V: Numeric: TypeMapper](f: T => Expr[V])(
def sumByOpt[V: TypeMapper](f: T => Expr[V])(
implicit qr: Queryable.Row[Expr[V], V]
): Expr[Option[V]] = v.aggregateExpr(expr => implicit ctx => sql"SUM(${f(expr)})")

/** Finds the minimum value in a column */
def minByOpt[V: Numeric: TypeMapper](f: T => Expr[V])(
def minByOpt[V: TypeMapper](f: T => Expr[V])(
implicit qr: Queryable.Row[Expr[V], V]
): Expr[Option[V]] = v.aggregateExpr(expr => implicit ctx => sql"MIN(${f(expr)})")

/** Finds the maximum value in a column */
def maxByOpt[V: Numeric: TypeMapper](f: T => Expr[V])(
def maxByOpt[V: TypeMapper](f: T => Expr[V])(
implicit qr: Queryable.Row[Expr[V], V]
): Expr[Option[V]] = v.aggregateExpr(expr => implicit ctx => sql"MAX(${f(expr)})")

/** Computes the average value of a column */
def avgByOpt[V: Numeric: TypeMapper](f: T => Expr[V])(
def avgByOpt[V: TypeMapper](f: T => Expr[V])(
implicit qr: Queryable.Row[Expr[V], V]
): Expr[Option[V]] = v.aggregateExpr(expr => implicit ctx => sql"AVG(${f(expr)})")