English | 简体中文

api-docs / org.ktorm.support.mysql

Package org.ktorm.support.mysql

MySQL dialect module for Ktorm.

Types

NameSummary

BulkInsertExpression

data class BulkInsertExpression : SqlExpression

Bulk insert expression, represents a bulk insert statement in MySQL.

BulkInsertOrUpdateOnDuplicateKeyClauseBuilder

class BulkInsertOrUpdateOnDuplicateKeyClauseBuilder : 
    MySqlAssignmentsBuilder

DSL builder for bulk insert or update on duplicate key clause.

BulkInsertOrUpdateStatementBuilder

class BulkInsertOrUpdateStatementBuilder<T : BaseTable<*>> : 
    BulkInsertStatementBuilder<T>

DSL builder for bulk insert or update statements.

BulkInsertStatementBuilder

open class BulkInsertStatementBuilder<T : BaseTable<*>>

DSL builder for bulk insert statements.

DefaultValueExpression

data class DefaultValueExpression<T : Any> : 
    ScalarExpression<T>

Default value expression, translated to the default keyword in MySQL, used in insert statements.

InsertOrUpdateExpression

data class InsertOrUpdateExpression : SqlExpression

Insert or update expression, represents an insert statement with an
on duplicate key update clause in MySQL.

InsertOrUpdateStatementBuilder

class InsertOrUpdateStatementBuilder : 
    MySqlAssignmentsBuilder

DSL builder for insert or update statements.

LockingClause

data class LockingClause

MySQL locking clause, See https://dev.mysql.com/doc/refman/8.0/en/innodb-locking-reads.html

LockingMode

enum class LockingMode

MySQL locking mode.

LockingWait

enum class LockingWait

MySQL wait strategy for locked records.

MatchAgainstExpression

data class MatchAgainstExpression : ScalarExpression<Boolean>

Match against expression, represents an match ... against ... operation in MySQL.
See https://dev.mysql.com/doc/refman/5.5/en/insert-on-duplicate.html

MatchColumns

class MatchColumns : List<ColumnExpression<*>>

Intermediate class that wraps the search columns of a MatchAgainstExpression.

MySqlAssignmentsBuilder

open class MySqlAssignmentsBuilder : AssignmentsBuilder

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

MySqlDialect

open class MySqlDialect : SqlDialect

SqlDialect implementation for MySQL database.

MySqlExpressionVisitor

interface MySqlExpressionVisitor : SqlExpressionVisitor

Base interface designed to visit or modify MySQL expression trees using visitor pattern.

MySqlFormatter

open class MySqlFormatter : 
    SqlFormatter,
    MySqlExpressionVisitor

SqlFormatter implementation for MySQL, formatting SQL expressions as strings with their execution arguments.

NaturalJoinExpression

data class NaturalJoinExpression : QuerySourceExpression

MySQL natural join expression.

SearchModifier

enum class SearchModifier

Enum class represents search modifiers in MySQL match ... against ... expressions.
See https://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html

Functions

NameSummary

against

fun MatchColumns.against(
    searchString: String,
    modifier: SearchModifier? = null
): MatchAgainstExpression

Create a MatchAgainstExpression that searches on the current MatchColumns.
Translated to match (col1, col2) against (searchString modifier) in SQL.

bulkInsert

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

fun <T : BaseTable<*>> T.bulkInsert(
    block: BulkInsertStatementBuilder<T>.() -> Unit
): Int

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

bulkInsertOrUpdate

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

fun <T : BaseTable<*>> T.bulkInsertOrUpdate(
    block: BulkInsertOrUpdateStatementBuilder<T>.() -> Unit
): Int

Bulk insert records to the table, determining if there is a key conflict while inserting each of them,
and automatically performs updates if any conflict exists.

dateDiff

fun dateDiff(
    left: ColumnDeclaring<LocalDate>,
    right: ColumnDeclaring<LocalDate>
): FunctionExpression<Int>

fun dateDiff(
    left: ColumnDeclaring<LocalDate>,
    right: LocalDate
): FunctionExpression<Int>

fun dateDiff(
    left: LocalDate,
    right: ColumnDeclaring<LocalDate>
): FunctionExpression<Int>

MySQL datediff function, translated to datediff(left, right).

defaultValue

fun <T : Any> Column<T>.defaultValue(): DefaultValueExpression<T>

Return a default value for this column, see DefaultValueExpression.

greatest

fun <T : Comparable<T>> greatest(
    vararg columns: ColumnDeclaring<T>
): FunctionExpression<T>

MySQL greatest function, translated to greatest(column1, column2, ...).

fun <T : Comparable<T>> greatest(
    left: ColumnDeclaring<T>,
    right: T
): FunctionExpression<T>

fun <T : Comparable<T>> greatest(
    left: T,
    right: ColumnDeclaring<T>
): FunctionExpression<T>

MySQL greatest function, translated to greatest(left, right).

IF

fun <T : Any> IF(
    condition: ColumnDeclaring<Boolean>,
    then: ColumnDeclaring<T>,
    otherwise: ColumnDeclaring<T>
): FunctionExpression<T>

fun <T : Any> IF(
    condition: ColumnDeclaring<Boolean>,
    then: T,
    otherwise: T,
    sqlType: SqlType<T> = SqlType.of() ?: error("Cannot detect the param's SqlType, please specify manually.")
): FunctionExpression<T>

MySQL if function, translated to if(condition, then, otherwise).

ifNull

fun <T : Any> ColumnDeclaring<T>.ifNull(
    right: ColumnDeclaring<T>
): FunctionExpression<T>

fun <T : Any> ColumnDeclaring<T>.ifNull(
    right: T?
): FunctionExpression<T>

MySQL ifnull function, translated to ifnull(left, right).

insertOrUpdate

fun <T : BaseTable<*>> T.insertOrUpdate(
    block: InsertOrUpdateStatementBuilder.(T) -> Unit
): Int

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

Insert a record to the table, determining if there is a key conflict while it’s being inserted, and automatically
performs an update if any conflict exists.

jsonContains

fun <T : Any> Column<List<T>>.jsonContains(
    item: T,
    sqlType: SqlType<T> = SqlType.of() ?: error("Cannot detect the item's SqlType, please specify manually.")
): FunctionExpression<Boolean>

MySQL json_contains function, translated to json_contains(column, json_array(item)).

jsonExtract

fun <T : Any> Column<*>.jsonExtract(
    path: String,
    sqlType: SqlType<T> = SqlType.of() ?: error("Cannot detect the result's SqlType, please specify manually.")
): FunctionExpression<T>

MySQL json_extract function, translated to json_extract(column, path).

least

fun <T : Comparable<T>> least(
    vararg columns: ColumnDeclaring<T>
): FunctionExpression<T>

MySQL least function, translated to least(column1, column2, ...).

fun <T : Comparable<T>> least(
    left: ColumnDeclaring<T>,
    right: T
): FunctionExpression<T>

fun <T : Comparable<T>> least(
    left: T,
    right: ColumnDeclaring<T>
): FunctionExpression<T>

MySQL least function, translated to least(left, right).

locking

fun Query.locking(
    mode: LockingMode,
    tables: List<BaseTable<*>> = emptyList(),
    wait: LockingWait = WAIT
): Query

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.locking(
    mode: LockingMode,
    tables: List<BaseTable<*>> = emptyList(),
    wait: LockingWait = WAIT
): EntitySequence<E, T>

Specify the locking clause of this query, an example generated SQL could be:

match

fun match(vararg columns: Column<*>): MatchColumns

Return an intermediate object that wraps the columns to be searched. We can continue to call against on the
returned object to create a MatchAgainstExpression that searches the wrapped columns.

naturalJoin

fun BaseTable<*>.naturalJoin(
    right: BaseTable<*>
): QuerySource

fun QuerySource.naturalJoin(right: BaseTable<*>): QuerySource

Join the right table and return a new QuerySource, translated to natural join in SQL.

rand

MySQL rand function, translated to rand().

replace

fun ColumnDeclaring<String>.replace(
    oldValue: String,
    newValue: String
): FunctionExpression<String>

MySQL replace function, translated to replace(str, oldValue, newValue).

toLowerCase

MySQL lower function, translated to lower(str).

toUpperCase

MySQL upper function, translated to upper(str).