English | 简体中文

api-docs / me.liuwj.ktorm.support.mysql

Package me.liuwj.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.

BulkInsertStatementBuilder

class BulkInsertStatementBuilder<T : BaseTable<>>

DSL builder for bulk 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 : AssignmentsBuilder

DSL builder for insert or update statements.

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.

MySqlDialect

open class MySqlDialect : SqlDialect

SqlDialect implementation for MySQL database.

MySqlExpressionVisitor

open class MySqlExpressionVisitor : SqlExpressionVisitor

Base class designed to visit or modify MySQL’s expression trees using visitor pattern.

MySqlFormatter

open class MySqlFormatter : SqlFormatter

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<>> 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.

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).

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).

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

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,
    itemSqlType: SqlType<T>
): FunctionExpression<Boolean>

infix fun Column<List<Int>>.jsonContains(
    item: Int
): FunctionExpression<Boolean>

infix fun Column<List<Long>>.jsonContains(
    item: Long
): FunctionExpression<Boolean>

infix fun Column<List<Double>>.jsonContains(
    item: Double
): FunctionExpression<Boolean>

infix fun Column<List<Float>>.jsonContains(
    item: Float
): FunctionExpression<Boolean>

infix fun Column<List<String>>.jsonContains(
    item: String
): 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>
): 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).

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 QuerySourceExpression.naturalJoin(
    right: BaseTable<>
): NaturalJoinExpression

fun BaseTable<>.naturalJoin(
    right: QuerySourceExpression
): NaturalJoinExpression

fun BaseTable<>.naturalJoin(
    right: BaseTable<>
): NaturalJoinExpression

Join the right table and return a NaturalJoinExpression, translated to natural join in MySQL.

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).