CompoundSelect

scalasql.query.CompoundSelect
See theCompoundSelect companion object
class CompoundSelect[Q, R](val lhs: SimpleSelect[Q, R], val compoundOps: Seq[Op[Q, R]], val orderBy: Seq[OrderBy], val limit: Option[Int], val offset: Option[Int])(implicit val qr: Row[Q, R], val dialect: DialectTypeMappers) extends Proxy[Q, R]

A SQL SELECT query, with ORDER BY, LIMIT, OFFSET, or UNION clauses

Attributes

Companion
object
Graph
Supertypes
trait Proxy[Q, R]
trait Select[Q, R]
trait Wrapped
trait DelegateQueryable[Q, Seq[R]]
trait Query[Seq[R]]
trait JoinOps[Select, Q, R]
trait Joinable[Q, R]
trait Aggregatable[Q]
trait WithSqlExpr[Q]
trait Renderable
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def asc: Select[Q, R]

Combined with sortBy to make the sort order ascending, translates into SQL ASC

Combined with sortBy to make the sort order ascending, translates into SQL ASC

Attributes

Definition Classes
override def compound0(op: String, other: Select[Q, R]): CompoundSelect[Q, R]

Attributes

Definition Classes
override def desc: Select[Q, R]

Combined with sortBy to make the sort order descending, translates into SQL DESC

Combined with sortBy to make the sort order descending, translates into SQL DESC

Attributes

Definition Classes
override def drop(n: Int): Select[Q, R]

Drops the first n rows from this Select. Like when used in Scala collections, if called multiple times the dropped rows add up

Drops the first n rows from this Select. Like when used in Scala collections, if called multiple times the dropped rows add up

Attributes

Definition Classes
override def filter(f: Q => Expr[Boolean]): Select[Q, R]

Filters this Select with the given predicate, translates into a SQL WHERE clause

Filters this Select with the given predicate, translates into a SQL WHERE clause

Attributes

Definition Classes
override def map[Q2, R2](f: Q => Q2)(implicit qr2: Row[Q2, R2]): Select[Q2, R2]

Transforms the return value of this Select with the given function

Transforms the return value of this Select with the given function

Attributes

Definition Classes
override def nullsFirst: Select[Q, R]

Combined with sortBy to configure handling of nulls, translates into SQL NULLS FIRST

Combined with sortBy to configure handling of nulls, translates into SQL NULLS FIRST

Attributes

Definition Classes
override def nullsLast: Select[Q, R]

Combined with sortBy to configure handling of nulls, translates into SQL NULLS LAST

Combined with sortBy to configure handling of nulls, translates into SQL NULLS LAST

Attributes

Definition Classes
override def sortBy(f: Q => Expr[_]): Select[Q, R]

Sorts this Select via the given expression. Translates into a SQL ORDER BY clause. Can be called more than once to sort on multiple columns, with the last call to sortBy taking priority. Can be followed by asc, desc, nullsFirst or nullsLast to configure the sort order

Sorts this Select via the given expression. Translates into a SQL ORDER BY clause. Can be called more than once to sort on multiple columns, with the last call to sortBy taking priority. Can be followed by asc, desc, nullsFirst or nullsLast to configure the sort order

Attributes

Definition Classes
override def take(n: Int): Select[Q, R]

Only returns the first n rows from this Select. Like when used in Scala collections, if called multiple times only the smallest value of n takes effect

Only returns the first n rows from this Select. Like when used in Scala collections, if called multiple times only the smallest value of n takes effect

Attributes

Definition Classes

Inherited methods

override def aggregate[E, V](f: (Proxy[Q]) => E)(implicit qr: Row[E, V]): Aggregate[E, V]

Performs one or more aggregates in a single Select

Performs one or more aggregates in a single Select

Attributes

Definition Classes
Inherited from:
Proxy
override def aggregateExpr[V : TypeMapper](f: Q => Context => SqlStr)(implicit evidence$1: TypeMapper[V], qr: Row[Expr[V], V]): Expr[V]

Attributes

Definition Classes
Proxy -> Aggregatable
Inherited from:
Proxy
def contains(other: Q): Expr[Boolean]

Returns whether or not the Select on the left contains the other value on the right

Returns whether or not the Select on the left contains the other value on the right

Attributes

Inherited from:
Select
def crossJoin[Q2, R2, QF, RF](other: Joinable[Q2, R2])(implicit ja: JoinAppend[Q, Q2, QF, RF]): Select[QF, RF]

Performs a CROSS JOIN, which is an INNER JOIN but without the ON clause

Performs a CROSS JOIN, which is an INNER JOIN but without the ON clause

Attributes

Inherited from:
JoinOps
def crossJoin[Q2, R2](): Mapper[Q, Q2, R, R2]

Version of crossJoin meant for usage in for-comprehensions

Version of crossJoin meant for usage in for-comprehensions

Attributes

Inherited from:
Joinable
def distinct: Select[Q, R]

Causes this Select to ignore duplicate rows, translates into SQL SELECT DISTINCT

Causes this Select to ignore duplicate rows, translates into SQL SELECT DISTINCT

Attributes

Inherited from:
Select
def except(other: Select[Q, R]): Select[Q, R]

Subtracts the other from this Select, returning only rows present this but absent in other, and removing duplicates. Translates into SQL EXCEPT

Subtracts the other from this Select, returning only rows present this but absent in other, and removing duplicates. Translates into SQL EXCEPT

Attributes

Inherited from:
Select
override def flatMap[Q2, R2](f: Q => Rhs[Q2, R2])(implicit qr: Row[Q2, R2]): Select[Q2, R2]

Performs an implicit JOIN between this Select and the one returned by the callback function f

Performs an implicit JOIN between this Select and the one returned by the callback function f

Attributes

Definition Classes
Inherited from:
Proxy
override def groupBy[K, V, R2, R3](groupKey: Q => K)(groupAggregate: (Proxy[Q]) => V)(implicit qrk: Row[K, R2], qrv: Row[V, R3]): Select[(K, V), (R2, R3)]

Translates into a SQL GROUP BY, takes a function specifying the group-key and a function specifying the group-aggregate.

Translates into a SQL GROUP BY, takes a function specifying the group-key and a function specifying the group-aggregate.

Attributes

Definition Classes
Inherited from:
Proxy
def head: Single[R]

Shorthand for .take(1).single:

Shorthand for .take(1).single:

  1. If the query returns a single row, this returns it as a single value of type R
  2. If the query returns multiple rows, returns the first as a single value of type R and discards the rest
  3. If the query returns zero rows, throws an exception.

Attributes

Inherited from:
Select
def intersect(other: Select[Q, R]): Select[Q, R]

Intersects the result rows of this Select with another, preserving only rows present in both this and the other and removing duplicates. Translates into SQL INTERSECT

Intersects the result rows of this Select with another, preserving only rows present in both this and the other and removing duplicates. Translates into SQL INTERSECT

Attributes

Inherited from:
Select
def isEmpty: Expr[Boolean]

Returns whether or not the Select on the left is empty with zero elements

Returns whether or not the Select on the left is empty with zero elements

Attributes

Inherited from:
Select
def join[Q2, R2, QF, RF](other: Joinable[Q2, R2])(on: (Q, Q2) => Expr[Boolean])(implicit ja: JoinAppend[Q, Q2, QF, RF]): Select[QF, RF]

Performs a JOIN/INNER JOIN on the given other, typically a Table or Select.

Performs a JOIN/INNER JOIN on the given other, typically a Table or Select.

Attributes

Inherited from:
JoinOps
def join[Q2, R2](on: Q => Expr[Boolean]): Mapper[Q, Q2, R, R2]

Version of join meant for usage in for-comprehensions

Version of join meant for usage in for-comprehensions

Attributes

Inherited from:
Joinable
override protected def join0[Q2, R2, QF, RF](prefix: String, other: Joinable[Q2, R2], on: Option[(Q, Q2) => Expr[Boolean]])(implicit ja: JoinAppend[Q, Q2, QF, RF]): Select[QF, RF]

Attributes

Definition Classes
Inherited from:
Proxy
override def leftJoin[Q2, R2](other: Joinable[Q2, R2])(on: (Q, Q2) => Expr[Boolean])(implicit joinQr: Row[Q2, R2]): Select[(Q, JoinNullable[Q2]), (R, Option[R2])]

Performs a LEFT JOIN on the given other, typically a Table or Select.

Performs a LEFT JOIN on the given other, typically a Table or Select.

Attributes

Definition Classes
Inherited from:
Proxy
def leftJoin[Q2, R2](on: Q => Expr[Boolean]): NullableMapper[Q, Q2, R, R2]

Version of leftJoin meant for usage in for-comprehensions

Version of leftJoin meant for usage in for-comprehensions

Attributes

Inherited from:
Joinable
override def mapAggregate[Q2, R2](f: (Q, Proxy[Q]) => Q2)(implicit qr: Row[Q2, R2]): Select[Q2, R2]

Performs a .map which additionally provides a Aggregatable.Proxy that allows you to perform aggregate functions.

Performs a .map which additionally provides a Aggregatable.Proxy that allows you to perform aggregate functions.

Attributes

Definition Classes
Inherited from:
Proxy
def nonEmpty: Expr[Boolean]

Returns whether or not the Select on the left is nonempty with one or more elements

Returns whether or not the Select on the left is nonempty with one or more elements

Attributes

Inherited from:
Select
override def outerJoin[Q2, R2](other: Joinable[Q2, R2])(on: (Q, Q2) => Expr[Boolean])(implicit joinQr: Row[Q2, R2]): Select[(JoinNullable[Q], JoinNullable[Q2]), (Option[R], Option[R2])]

Performs a OUTER JOIN on the given other, typically a Table or Select.

Performs a OUTER JOIN on the given other, typically a Table or Select.

Attributes

Definition Classes
Inherited from:
Proxy
override protected def queryConstruct(args: ResultSetIterator): Seq[R]

Attributes

Definition Classes
Inherited from:
Proxy
override protected def queryIsExecuteUpdate: Boolean

Attributes

Definition Classes
Inherited from:
DelegateQueryable
protected def queryWalkExprs(): Seq[Expr[_]]

Attributes

Inherited from:
DelegateQueryable
protected def queryWalkLabels(): Seq[List[String]]

Attributes

Inherited from:
DelegateQueryable
override def rightJoin[Q2, R2](other: Joinable[Q2, R2])(on: (Q, Q2) => Expr[Boolean])(implicit joinQr: Row[Q2, R2]): Select[(JoinNullable[Q], Q2), (Option[R], R2)]

Performs a RIGHT JOIN on the given other, typically a Table or Select.

Performs a RIGHT JOIN on the given other, typically a Table or Select.

Attributes

Definition Classes
Inherited from:
Proxy
override protected def selectWithExprPrefix(preserveAll: Boolean, s: Context => SqlStr): Select[Q, R]

Attributes

Definition Classes
Inherited from:
Proxy
def single: Single[R]

Asserts that this query returns exactly one row, and returns a single value of type R rather than a Seq[R]. Throws an exception if zero or multiple rows are returned.

Asserts that this query returns exactly one row, and returns a single value of type R rather than a Seq[R]. Throws an exception if zero or multiple rows are returned.

Attributes

Inherited from:
Select
def subquery: SimpleSelect[Q, R]

Forces this Select to be treated as a subquery that any further operations will operate on, rather than having some operations flattened out into clauses in this Select

Forces this Select to be treated as a subquery that any further operations will operate on, rather than having some operations flattened out into clauses in this Select

Attributes

Inherited from:
Select
def toExpr(implicit mt: TypeMapper[R]): Expr[R]

Converts this Select into an Expr, assuming it returns a single row and a single column. Note that if this returns multiple rows, behavior is database-specific, with some like Sqlite simply taking the first row while others like Postgres/MySql throwing exceptions

Converts this Select into an Expr, assuming it returns a single row and a single column. Note that if this returns multiple rows, behavior is database-specific, with some like Sqlite simply taking the first row while others like Postgres/MySql throwing exceptions

Attributes

Inherited from:
Select
def union(other: Select[Q, R]): Select[Q, R]

Concatenates the result rows of this Select with another and removes duplicate rows; translates into SQL UNION

Concatenates the result rows of this Select with another and removes duplicate rows; translates into SQL UNION

Attributes

Inherited from:
Select
def unionAll(other: Select[Q, R]): Select[Q, R]

Concatenates the result rows of this Select with another; translates into SQL UNION ALL

Concatenates the result rows of this Select with another; translates into SQL UNION ALL

Attributes

Inherited from:
Select
def withFilter(f: Q => Expr[Boolean]): Select[Q, R]

Alias for filter

Alias for filter

Attributes

Inherited from:
Select

Concrete fields

val compoundOps: Seq[Op[Q, R]]
val lhs: SimpleSelect[Q, R]
val limit: Option[Int]
val offset: Option[Int]
val orderBy: Seq[OrderBy]

Implicits

Implicits

implicit val dialect: DialectTypeMappers
implicit val qr: Row[Q, R]