All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
calasql-query_3.0.1.5.source-code.Joinable.scala Maven / Gradle / Ivy
package scalasql.query
import scalasql.core.{Context, Expr, JoinNullable}
/**
* Something that can be joined; typically a [[Select]] or a [[Table]]
*/
trait Joinable[Q, R] {
protected def joinableToFromExpr: (Context.From, Q)
/**
* Version of `crossJoin` meant for usage in `for`-comprehensions
*/
def crossJoin[Q2, R2](): FlatJoin.Mapper[Q, Q2, R, R2] = {
val (from, expr) = joinableToFromExpr
new FlatJoin.Mapper[Q, Q2, R, R2]("CROSS JOIN", from, expr, None, Nil)
}
/**
* Version of `join` meant for usage in `for`-comprehensions
*/
def join[Q2, R2](on: Q => Expr[Boolean]): FlatJoin.Mapper[Q, Q2, R, R2] = {
val (from, expr) = joinableToFromExpr
new FlatJoin.Mapper[Q, Q2, R, R2]("JOIN", from, expr, Some(on(expr)), Nil)
}
/**
* Version of `leftJoin` meant for usage in `for`-comprehensions
*/
def leftJoin[Q2, R2](on: Q => Expr[Boolean]): FlatJoin.NullableMapper[Q, Q2, R, R2] = {
val (from, expr) = joinableToFromExpr
new FlatJoin.NullableMapper[Q, Q2, R, R2](
"LEFT JOIN",
from,
JoinNullable(expr),
Some(on(expr)),
Nil
)
}
}
object Joinable {
def toFromExpr[Q, R](x: Joinable[Q, R]) = x.joinableToFromExpr
}