English | 简体中文

api-docs / org.ktorm.dsl

Package org.ktorm.dsl

Constructs strong-typed SQL DSL.

Types

NameSummary

AliasRemover

object AliasRemover : SqlExpressionVisitorInterceptor

Expression visitor interceptor for removing table aliases, used by Ktorm internally.

AssignmentsBuilder

open class AssignmentsBuilder

Base class of DSL builders, provide basic functions used to build assignments for insert or update DSL.

BatchInsertStatementBuilder

class BatchInsertStatementBuilder<T : BaseTable<*>>

DSL builder for batch insert statements.

BatchUpdateStatementBuilder

class BatchUpdateStatementBuilder<T : BaseTable<*>>

DSL builder for batch update statements.

CaseWhen

data class CaseWhen<T : Any, R : Any>

Helper class used to build case-when SQL DSL. See CaseWhenExpression.

Query

class Query

Query is an abstraction of query operations and the core class of Ktorm’s query DSL.

QueryRowSet

class QueryRowSet : CachedRowSet

Special implementation of ResultSet, used to hold the Query results for Ktorm.

QuerySource

data class QuerySource

Represents a query source, used in the from clause of a query.

UpdateStatementBuilder

class UpdateStatementBuilder : AssignmentsBuilder

DSL builder for update statements.

WhenContinuation

data class WhenContinuation<T : Any, R : Any>

Return type for WHEN function, call its extension function THEN to finish a SQL when clause.

WindowFrames

object WindowFrames

Utility object that creates expressions of window frame bounds.

Annotations

NameSummary

KtormDsl

annotation class KtormDsl

Marker annotation for Ktorm DSL builder classes.

Extensions for External Classes

NameSummary

kotlin.Boolean

kotlin.collections.Iterable

Functions

NameSummary

and


infix fun ColumnDeclaring<Boolean>.and(
    value: Boolean
): BinaryExpression<Boolean>

And operator, translated to the and keyword in SQL.

asc

Order this column or expression in ascending order.

asIterable

fun Query.asIterable(): Iterable<QueryRowSet>

Wrap this query as Iterable.

associate

fun <K, V> Query.associate(
    transform: (row: QueryRowSet) -> Pair<K, V>
): Map<K, V>

Return a Map containing key-value pairs provided by transform function applied to rows of the query.

associateBy

fun <K, V> Query.associateBy(
    keySelector: (row: QueryRowSet) -> K,
    valueTransform: (row: QueryRowSet) -> V
): Map<K, V>

Return a Map containing the values provided by valueTransform and indexed by keySelector functions applied to
rows of the query.

associateByTo

fun <K, V, M : MutableMap<in K, in V>> Query.associateByTo(
    destination: M,
    keySelector: (row: QueryRowSet) -> K,
    valueTransform: (row: QueryRowSet) -> V
): M

Populate and return the destination mutable map with key-value pairs, where key is provided by the keySelector
function and value is provided by the valueTransform function applied to rows of the query.

associateTo

fun <K, V, M : MutableMap<in K, in V>> Query.associateTo(
    destination: M,
    transform: (row: QueryRowSet) -> Pair<K, V>
): M

Populate and return the destination mutable map with key-value pairs provided by transform function applied to
each row of the query.

avg

fun <C : Number> avg(
    column: ColumnDeclaring<C>
): AggregateExpression<Double>

The avg function, translated to avg(column) in SQL.

avgDistinct

fun <C : Number> avgDistinct(
    column: ColumnDeclaring<C>
): AggregateExpression<Double>

The avg function with distinct, translated to avg(distinct column) in SQL.

batchInsert

fun <T : BaseTable<*>> Database.batchInsert(
    table: T,
    block: BatchInsertStatementBuilder<T>.() -> Unit
): IntArray

Construct insert expressions in the given closure, then batch execute them and return the effected
row counts for each expression.

batchUpdate

fun <T : BaseTable<*>> Database.batchUpdate(
    table: T,
    block: BatchUpdateStatementBuilder<T>.() -> Unit
): IntArray

Construct update expressions in the given closure, then batch execute them and return the effected
row counts for each expression.

between

infix fun <T : Comparable<T>> ColumnDeclaring<T>.between(
    range: ClosedRange<T>
): BetweenExpression

Between operator, translated to between .. and .. in SQL.

CASE

fun CASE(): CaseWhen<Boolean, Nothing>

Starts a searched case-when DSL.

fun <T : Any> CASE(
    operand: ColumnDeclaring<T>
): CaseWhen<T, Nothing>

Starts a simple case-when DSL with the given operand.

cast

fun <T : Any> ColumnDeclaring<*>.cast(
    sqlType: SqlType<T>
): CastingExpression<T>

Cast the current column or expression to the given SqlType.

count

fun count(
    column: ColumnDeclaring<*>? = null
): AggregateExpression<Int>

The count function, translated to count(column) in SQL.

countDistinct

fun countDistinct(
    column: ColumnDeclaring<*>? = null
): AggregateExpression<Int>

The count function with distinct, translated to count(distinct column) in SQL.

crossJoin

fun QuerySource.crossJoin(
    right: BaseTable<*>,
    on: ColumnDeclaring<Boolean>? = null
): QuerySource

Perform a cross join and return a new QuerySource, translated to cross join in SQL.

cumeDist

The cume_dist window function, translated to cume_dist() in SQL.

delete

fun <T : BaseTable<*>> Database.delete(
    table: T,
    predicate: (T) -> ColumnDeclaring<Boolean>
): Int

Delete the records in the table that matches the given predicate.

deleteAll

fun Database.deleteAll(table: BaseTable<*>): Int

Delete all the records in the table.

denseRank

fun denseRank(): WindowFunctionExpression<Int>

The dense_rank window function, translated to dense_rank() in SQL.

desc

Order this column or expression in descending order, corresponding to the desc keyword in SQL.

div

infix operator fun <T : Number> ColumnDeclaring<T>.div(
    expr: ColumnDeclaring<T>
): BinaryExpression<T>

infix operator fun <T : Number> ColumnDeclaring<T>.div(
    value: T
): BinaryExpression<T>

infix operator fun <T : Number> T.div(
    expr: ColumnDeclaring<T>
): BinaryExpression<T>

Divide operator, translated to / in SQL.

ELSE

fun <T : Any, R : Any> CaseWhen<T, R>.ELSE(
    result: ColumnDeclaring<R>
): CaseWhen<T, R>

fun <T : Any, R : Any> CaseWhen<T, R>.ELSE(
    result: R,
    sqlType: SqlType<R> = SqlType.of() ?: error("Cannot detect the argument's SqlType, please specify manually.")
): CaseWhen<T, R>

Specifies the else clause for the case-when DSL.

END

fun <R : Any> CaseWhen<*, R>.END(): CaseWhenExpression<R>

Finishes the case-when DSL and returns a CaseWhenExpression.

eq

infix fun <T : Any> ColumnDeclaring<T>.eq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

infix fun <T : Any> ColumnDeclaring<T>.eq(
    value: T
): BinaryExpression<Boolean>

infix fun <T : Any> T.eq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Equal operator, translated to = in SQL.

exists

fun exists(query: Query): ExistsExpression

Check if the given query has at least one result, translated to the exists keyword in SQL.

firstValue

fun <T : Any> firstValue(
    expr: ColumnDeclaring<T>
): WindowFunctionExpression<T>

The first_value window function, translated to first_value(expr) in SQL.

flatMap

fun <R> Query.flatMap(
    transform: (row: QueryRowSet) -> Iterable<R>
): List<R>

Return a single list of all elements yielded from results of transform function being invoked on each row
of the query.

flatMapIndexed

fun <R> Query.flatMapIndexed(
    transform: (index: Int, row: QueryRowSet) -> Iterable<R>
): List<R>

Return a single list of all elements yielded from results of transform function being invoked on each row
and its index in the query.

flatMapIndexedTo

fun <R, C : MutableCollection<in R>> Query.flatMapIndexedTo(
    destination: C,
    transform: (index: Int, row: QueryRowSet) -> Iterable<R>
): C

Append all elements yielded from results of transform function being invoked on each row and its index
in the query, to the given destination.

flatMapTo

fun <R, C : MutableCollection<in R>> Query.flatMapTo(
    destination: C,
    transform: (row: QueryRowSet) -> Iterable<R>
): C

Append all elements yielded from results of transform function being invoked on each row of the query,
to the given destination.

fold

fun <R> Query.fold(
    initial: R,
    operation: (acc: R, row: QueryRowSet) -> R
): R

Accumulate value starting with initial value and applying operation to current accumulator value and each row.

foldIndexed

fun <R> Query.foldIndexed(
    initial: R,
    operation: (index: Int, acc: R, row: QueryRowSet) -> R
): R

Accumulate value starting with initial value and applying operation to current accumulator value and each row
with its index in the original query results.

forEach

fun Query.forEach(action: (row: QueryRowSet) -> Unit): Unit

Perform the given action on each row of the query.

forEachIndexed

fun Query.forEachIndexed(
    action: (index: Int, row: QueryRowSet) -> Unit
): Unit

Perform the given action on each row of the query, providing sequential index with the row.

from

fun Database.from(table: BaseTable<*>): QuerySource

Wrap the specific table as a QuerySource.

fullJoin

fun QuerySource.fullJoin(
    right: BaseTable<*>,
    on: ColumnDeclaring<Boolean>? = null
): QuerySource

Perform a full join and return a new QuerySource, translated to full join in SQL.

greater

infix fun <T : Comparable<T>> ColumnDeclaring<T>.greater(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> ColumnDeclaring<T>.greater(
    value: T
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> T.greater(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Greater operator, translated to > in SQL.

greaterEq

infix fun <T : Comparable<T>> ColumnDeclaring<T>.greaterEq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> ColumnDeclaring<T>.greaterEq(
    value: T
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> T.greaterEq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Greater-eq operator, translated to >= in SQL.

groupBy

fun Query.groupBy(
    columns: Collection<ColumnDeclaring<*>>
): Query

fun Query.groupBy(vararg columns: ColumnDeclaring<*>): Query

Specify the group by clause of this query using the given columns or expressions.

gt

infix fun <T : Comparable<T>> ColumnDeclaring<T>.gt(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> ColumnDeclaring<T>.gt(
    value: T
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> T.gt(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Greater operator, translated to > in SQL.

gte

infix fun <T : Comparable<T>> ColumnDeclaring<T>.gte(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> ColumnDeclaring<T>.gte(
    value: T
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> T.gte(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Greater-eq operator, translated to >= in SQL.

having

fun Query.having(condition: ColumnDeclaring<Boolean>): Query

Specify the having clause of this query using the given condition expression.

fun Query.having(
    condition: () -> ColumnDeclaring<Boolean>
): Query

Specify the having clause of this query using the expression returned by the given callback function.

inList

fun <T : Any> ColumnDeclaring<T>.inList(
    vararg list: T
): InListExpression

infix fun <T : Any> ColumnDeclaring<T>.inList(
    list: Collection<T>
): InListExpression

infix fun ColumnDeclaring<*>.inList(
    query: Query
): InListExpression

In-list operator, translated to the in keyword in SQL.

innerJoin

fun QuerySource.innerJoin(
    right: BaseTable<*>,
    on: ColumnDeclaring<Boolean>? = null
): QuerySource

Perform an inner join and return a new QuerySource, translated to inner join in SQL.

insert

fun <T : BaseTable<*>> Database.insert(
    table: T,
    block: AssignmentsBuilder.(T) -> Unit
): Int

Construct an insert expression in the given closure, then execute it and return the effected row count.

insertAndGenerateKey

fun <T : BaseTable<*>> Database.insertAndGenerateKey(
    table: T,
    block: AssignmentsBuilder.(T) -> Unit
): Any

Construct an insert expression in the given closure, then execute it and return the auto-generated key.

insertTo

fun Query.insertTo(
    table: BaseTable<*>,
    vararg columns: Column<*>
): Int

Insert the current Query‘s results into the given table, useful when transfer data from a table to another table.

isNotNull

Check if the current column or expression is not null, translated to is not null in SQL.

isNull

Check if the current column or expression is null, translated to is null in SQL.

joinReferencesAndSelect

fun QuerySource.joinReferencesAndSelect(): Query

Return a new-created Query object, left joining all the reference tables, and selecting all columns of them.

joinTo

fun <A : Appendable> Query.joinTo(
    buffer: A,
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (row: QueryRowSet) -> CharSequence
): A

Append the string from all rows separated using separator and using the given prefix and postfix if supplied.

joinToString

fun Query.joinToString(
    separator: CharSequence = ", ",
    prefix: CharSequence = "",
    postfix: CharSequence = "",
    limit: Int = -1,
    truncated: CharSequence = "...",
    transform: (row: QueryRowSet) -> CharSequence
): String

Create a string from all rows separated using separator and using the given prefix and postfix if supplied.

lag

fun <T : Any> lag(
    expr: ColumnDeclaring<T>,
    offset: Int = 1,
    defVal: T? = null
): WindowFunctionExpression<T>

fun <T : Any> lag(
    expr: ColumnDeclaring<T>,
    offset: Int,
    defVal: ColumnDeclaring<T>
): WindowFunctionExpression<T>

The lag window function, translated to lag(expr, offset[, defVal]) in SQL.

lastValue

fun <T : Any> lastValue(
    expr: ColumnDeclaring<T>
): WindowFunctionExpression<T>

The last_value window function, translated to last_value(expr) in SQL.

lead

fun <T : Any> lead(
    expr: ColumnDeclaring<T>,
    offset: Int = 1,
    defVal: T? = null
): WindowFunctionExpression<T>

fun <T : Any> lead(
    expr: ColumnDeclaring<T>,
    offset: Int,
    defVal: ColumnDeclaring<T>
): WindowFunctionExpression<T>

The lead window function, translated to lead(expr, offset[, defVal]) in SQL.

leftJoin

fun QuerySource.leftJoin(
    right: BaseTable<*>,
    on: ColumnDeclaring<Boolean>? = null
): QuerySource

Perform a left join and return a new QuerySource, translated to left join in SQL.

less

infix fun <T : Comparable<T>> ColumnDeclaring<T>.less(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> ColumnDeclaring<T>.less(
    value: T
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> T.less(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Less operator, translated to < in SQL.

lessEq

infix fun <T : Comparable<T>> ColumnDeclaring<T>.lessEq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> ColumnDeclaring<T>.lessEq(
    value: T
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> T.lessEq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Less-eq operator, translated to <= in SQL.

like

infix fun ColumnDeclaring<*>.like(
    expr: ColumnDeclaring<String>
): BinaryExpression<Boolean>

infix fun ColumnDeclaring<*>.like(
    value: String
): BinaryExpression<Boolean>

Like operator, translated to the like keyword in SQL.

limit

fun Query.limit(n: Int): Query

Specify the pagination limit parameter of this query.

fun Query.limit(offset: Int?, limit: Int?): Query

Specify the pagination parameters of this query.

lt

infix fun <T : Comparable<T>> ColumnDeclaring<T>.lt(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> ColumnDeclaring<T>.lt(
    value: T
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> T.lt(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Less operator, translated to < in SQL.

lte

infix fun <T : Comparable<T>> ColumnDeclaring<T>.lte(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> ColumnDeclaring<T>.lte(
    value: T
): BinaryExpression<Boolean>

infix fun <T : Comparable<T>> T.lte(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Less-eq operator, translated to <= in SQL.

map

fun <R> Query.map(
    transform: (row: QueryRowSet) -> R
): List<R>

Return a list containing the results of applying the given transform function to each row of the query.

mapIndexed

fun <R> Query.mapIndexed(
    transform: (index: Int, row: QueryRowSet) -> R
): List<R>

Return a list containing the results of applying the given transform function to each row and its index.

mapIndexedNotNull

fun <R : Any> Query.mapIndexedNotNull(
    transform: (index: Int, row: QueryRowSet) -> R?
): List<R>

Return a list containing only the non-null results of applying the given transform function to each row
and its index.

mapIndexedNotNullTo

fun <R : Any, C : MutableCollection<in R>> Query.mapIndexedNotNullTo(
    destination: C,
    transform: (index: Int, row: QueryRowSet) -> R?
): C

Apply the given transform function to each row and its index and append only the non-null results to
the given destination.

mapIndexedTo

fun <R, C : MutableCollection<in R>> Query.mapIndexedTo(
    destination: C,
    transform: (index: Int, row: QueryRowSet) -> R
): C

Apply the given transform function to each row and its index and append the results to the given destination.

mapNotNull

fun <R : Any> Query.mapNotNull(
    transform: (row: QueryRowSet) -> R?
): List<R>

Return a list containing only the non-null results of applying the given transform function to each row of
the query.

mapNotNullTo

fun <R : Any, C : MutableCollection<in R>> Query.mapNotNullTo(
    destination: C,
    transform: (row: QueryRowSet) -> R?
): C

Apply the given transform function to each row of the query and append only the non-null results to
the given destination.

mapTo

fun <R, C : MutableCollection<in R>> Query.mapTo(
    destination: C,
    transform: (row: QueryRowSet) -> R
): C

Apply the given transform function to each row of the query and append the results to the given destination.

max

fun <C : Comparable<C>> max(
    column: ColumnDeclaring<C>
): AggregateExpression<C>

The max function, translated to max(column) in SQL.

maxDistinct

fun <C : Comparable<C>> maxDistinct(
    column: ColumnDeclaring<C>
): AggregateExpression<C>

The max function with distinct, translated to max(distinct column) in SQL.

min

fun <C : Comparable<C>> min(
    column: ColumnDeclaring<C>
): AggregateExpression<C>

The min function, translated to min(column) in SQL.

minDistinct

fun <C : Comparable<C>> minDistinct(
    column: ColumnDeclaring<C>
): AggregateExpression<C>

The min function with distinct, translated to min(distinct column) in SQL.

minus

infix operator fun <T : Number> ColumnDeclaring<T>.minus(
    expr: ColumnDeclaring<T>
): BinaryExpression<T>

infix operator fun <T : Number> ColumnDeclaring<T>.minus(
    value: T
): BinaryExpression<T>

infix operator fun <T : Number> T.minus(
    expr: ColumnDeclaring<T>
): BinaryExpression<T>

Minus operator, translated to - in SQL.

neq

infix fun <T : Any> ColumnDeclaring<T>.neq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

infix fun <T : Any> ColumnDeclaring<T>.neq(
    value: T
): BinaryExpression<Boolean>

infix fun <T : Any> T.neq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Not-equal operator, translated to <> in SQL.

not

Negative operator, translated to the not keyword in SQL.

notBetween

infix fun <T : Comparable<T>> ColumnDeclaring<T>.notBetween(
    range: ClosedRange<T>
): BetweenExpression

Not-between operator, translated to not between .. and .. in SQL.

notEq

infix fun <T : Any> ColumnDeclaring<T>.notEq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

infix fun <T : Any> ColumnDeclaring<T>.notEq(
    value: T
): BinaryExpression<Boolean>

infix fun <T : Any> T.notEq(
    expr: ColumnDeclaring<T>
): BinaryExpression<Boolean>

Not-equal operator, translated to <> in SQL.

notExists

fun notExists(query: Query): ExistsExpression

Check if the given query doesn’t have any results, translated to the not exists keyword in SQL.

notInList

fun <T : Any> ColumnDeclaring<T>.notInList(
    vararg list: T
): InListExpression

infix fun <T : Any> ColumnDeclaring<T>.notInList(
    list: Collection<T>
): InListExpression

infix fun ColumnDeclaring<*>.notInList(
    query: Query
): InListExpression

Not-in-list operator, translated to the not in keyword in SQL.

notLike

infix fun ColumnDeclaring<*>.notLike(
    expr: ColumnDeclaring<String>
): BinaryExpression<Boolean>

infix fun ColumnDeclaring<*>.notLike(
    value: String
): BinaryExpression<Boolean>

Not like operator, translated to the not like keyword in SQL.

nthValue

fun <T : Any> nthValue(
    expr: ColumnDeclaring<T>,
    n: Int
): WindowFunctionExpression<T>

The nth_value window function, translated to nth_value(expr, n) in SQL.

ntile

The ntile window function, translated to ntile(n) in SQL.

offset

fun Query.offset(n: Int): Query

Specify the pagination offset parameter of this query.

or


infix fun ColumnDeclaring<Boolean>.or(
    value: Boolean
): BinaryExpression<Boolean>

Or operator, translated to the or keyword in SQL.

orderBy

fun Query.orderBy(
    orders: Collection<OrderByExpression>
): Query

fun Query.orderBy(vararg orders: OrderByExpression): Query

Specify the order by clause of this query using the given order-by expressions.


Specify the order-by clause of this window using the given order-by expressions.

over

fun <T : Any> WindowFunctionExpression<T>.over(
    window: WindowSpecificationExpression = window()
): WindowFunctionExpression<T>

Specify the window specification for this window function.

fun <T : Any> AggregateExpression<T>.over(
    window: WindowSpecificationExpression = window()
): WindowFunctionExpression<T>

Use this aggregate function as a window function and specify its window specification.

partitionBy


Specify the partition-by clause of this window using the given columns or expressions.

percentRank

fun percentRank(): WindowFunctionExpression<Double>

The percent_rank window function, translated to percent_rank() in SQL.

plus

infix operator fun <T : Number> ColumnDeclaring<T>.plus(
    expr: ColumnDeclaring<T>
): BinaryExpression<T>

infix operator fun <T : Number> ColumnDeclaring<T>.plus(
    value: T
): BinaryExpression<T>

infix operator fun <T : Number> T.plus(
    expr: ColumnDeclaring<T>
): BinaryExpression<T>

Plus operator, translated to + in SQL.

range

Specify the frame clause of this window using the given bound in range unit.

rangeBetween

Specify the frame clause of this window using the given bounds (start & end) in rows unit.

rank

The rank window function, translated to rank() in SQL.

rem

infix operator fun <T : Number> ColumnDeclaring<T>.rem(
    expr: ColumnDeclaring<T>
): BinaryExpression<T>

infix operator fun <T : Number> ColumnDeclaring<T>.rem(
    value: T
): BinaryExpression<T>

infix operator fun <T : Number> T.rem(
    expr: ColumnDeclaring<T>
): BinaryExpression<T>

Mod operator, translated to % in SQL.

rightJoin

fun QuerySource.rightJoin(
    right: BaseTable<*>,
    on: ColumnDeclaring<Boolean>? = null
): QuerySource

Perform a right join and return a new QuerySource, translated to right join in SQL.

rowNumber

fun rowNumber(): WindowFunctionExpression<Int>

The row_number window function, translated to row_number() in SQL.

rows

Specify the frame clause of this window using the given bound in rows unit.

rowsBetween

Specify the frame clause of this window using the given bounds (start & end) in rows unit.

select

fun QuerySource.select(
    columns: Collection<ColumnDeclaring<*>>
): Query

fun QuerySource.select(
    vararg columns: ColumnDeclaring<*>
): Query

Create a query object, selecting the specific columns or expressions from this QuerySource.

selectDistinct

fun QuerySource.selectDistinct(
    columns: Collection<ColumnDeclaring<*>>
): Query

fun QuerySource.selectDistinct(
    vararg columns: ColumnDeclaring<*>
): Query

Create a query object, selecting the specific columns or expressions from this QuerySource distinctly.

sum

fun <C : Number> sum(
    column: ColumnDeclaring<C>
): AggregateExpression<C>

The sum function, translated to sum(column) in SQL.

sumDistinct

fun <C : Number> sumDistinct(
    column: ColumnDeclaring<C>
): AggregateExpression<C>

The sum function with distinct, translated to sum(distinct column) in SQL.

THEN

fun <T : Any, R : Any> WhenContinuation<T, Nothing>.THEN(
    result: ColumnDeclaring<R>
): CaseWhen<T, R>

fun <T : Any, R : Any> WhenContinuation<T, Nothing>.THEN(
    result: R,
    sqlType: SqlType<R> = SqlType.of() ?: error("Cannot detect the argument's SqlType, please specify manually.")
): CaseWhen<T, R>

fun <T : Any, R : Any> WhenContinuation<T, R>.THEN(
    result: ColumnDeclaring<R>
): CaseWhen<T, R>

fun <T : Any, R : Any> WhenContinuation<T, R>.THEN(
    result: R,
    sqlType: SqlType<R> = SqlType.of() ?: error("Cannot detect the argument's SqlType, please specify manually.")
): CaseWhen<T, R>

Finishes the current when clause with the given result.

times

infix operator fun <T : Number> ColumnDeclaring<T>.times(
    expr: ColumnDeclaring<T>
): BinaryExpression<T>

infix operator fun <T : Number> ColumnDeclaring<T>.times(
    value: T
): BinaryExpression<T>

infix operator fun <T : Number> T.times(
    expr: ColumnDeclaring<T>
): BinaryExpression<T>

Multiply operator, translated to * in SQL.

toDouble

Cast the current column or expression’s type to Double.

toFloat

Cast the current column or expression’s type to Float.

toInt


Cast the current column or expression’s type to Int.

toLong

Cast the current column or expression’s type to Long.

toShort

Cast the current column or expression’s type to Short.

unaryMinus

operator fun <T : Number> ColumnDeclaring<T>.unaryMinus(): UnaryExpression<T>

Unary minus operator, translated to - in SQL.

unaryPlus

operator fun <T : Number> ColumnDeclaring<T>.unaryPlus(): UnaryExpression<T>

Unary plus operator, translated to + in SQL.

union

fun Query.union(right: Query): Query

Union this query with the given one, corresponding to the union keyword in SQL.

unionAll

fun Query.unionAll(right: Query): Query

Union this query with the given one, corresponding to the union all keyword in SQL.

update

fun <T : BaseTable<*>> Database.update(
    table: T,
    block: UpdateStatementBuilder.(T) -> Unit
): Int

Construct an update expression in the given closure, then execute it and return the effected row count.

WHEN

fun <T : Any, R : Any> CaseWhen<T, R>.WHEN(
    condition: ColumnDeclaring<T>
): WhenContinuation<T, R>

fun <T : Any, R : Any> CaseWhen<T, R>.WHEN(
    condition: T,
    sqlType: SqlType<T> = SqlType.of() ?: error("Cannot detect the argument's SqlType, please specify manually.")
): WhenContinuation<T, R>

Starts a when clause with the given condition.

where

fun Query.where(condition: ColumnDeclaring<Boolean>): Query

Specify the where clause of this query using the given condition expression.

fun Query.where(
    condition: () -> ColumnDeclaring<Boolean>
): Query

Specify the where clause of this query using the expression returned by the given callback function.

whereWithConditions

fun Query.whereWithConditions(
    block: (MutableList<ColumnDeclaring<Boolean>>) -> Unit
): Query

Create a mutable list, then add filter conditions to the list in the given callback function, finally combine
them with the and operator and set the combined condition as the where clause of this query.

whereWithOrConditions

fun Query.whereWithOrConditions(
    block: (MutableList<ColumnDeclaring<Boolean>>) -> Unit
): Query

Create a mutable list, then add filter conditions to the list in the given callback function, finally combine
them with the or operator and set the combined condition as the where clause of this query.

window

Create a default window specification.

withIndex

Return a lazy Iterable that wraps each row of the query into an IndexedValue containing the index of
that row and the row itself.

xor


infix fun ColumnDeclaring<Boolean>.xor(
    value: Boolean
): BinaryExpression<Boolean>

Xor operator, translated to the xor keyword in SQL.