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

calasql-operations_3.0.1.9.source-code.ConcatOps.scala Maven / Gradle / Ivy

package scalasql.operations
import scalasql.core.{Expr, SqlStr}
import scalasql.core.SqlStr.SqlStringSyntax

trait ConcatOps {

  /**
   * Concatenate all arguments. NULL arguments are ignored.
   */
  def concat(values: Expr[?]*): Expr[String] = Expr { implicit ctx =>
    sql"CONCAT(${SqlStr.join(values.map(v => sql"$v"), SqlStr.commaSep)})"
  }

  /**
   * Concatenate all but first arguments with separators. The first parameter is used
   * as a separator. NULL arguments are ignored.
   */
  def concatWs(sep: Expr[String], values: Expr[?]*): Expr[String] = Expr { implicit ctx =>
    sql"CONCAT_WS($sep, ${SqlStr.join(values.map(v => sql"$v"), SqlStr.commaSep)})"
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy