English | 简体中文

api-docs / org.ktorm.support.postgresql

Package org.ktorm.support.postgresql

PostgreSQL dialect module for Ktorm.

Types

NameSummary

BulkInsertExpression

data class BulkInsertExpression : SqlExpression

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

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.

HStoreExpression

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

Expression class represents PostgreSQL’s hstore operations.

HStoreExpressionType

enum class HStoreExpressionType

Enum for hstore operators.

HStoreSqlType

object HStoreSqlType : SqlType<HStore>

SqlType implementation represents PostgreSQL hstore type.

ILikeExpression

data class ILikeExpression : ScalarExpression<Boolean>

ILike expression, represents PostgreSQL’s ilike keyword.

InsertOrUpdateExpression

data class InsertOrUpdateExpression : SqlExpression

Insert or update expression, represents an insert statement with an
on conflict (key) do update set clause in PostgreSQL.

InsertOrUpdateOnConflictClauseBuilder

class InsertOrUpdateOnConflictClauseBuilder : 
    PostgreSqlAssignmentsBuilder

DSL builder for insert or update on conflict clause.

InsertOrUpdateStatementBuilder

class InsertOrUpdateStatementBuilder : 
    PostgreSqlAssignmentsBuilder

DSL builder for insert or update statements.

LockingClause

data class LockingClause

PostgreSQL locking clause. See https://www.postgresql.org/docs/13/sql-select.html#SQL-FOR-UPDATE-SHARE

LockingMode

enum class LockingMode

PostgreSQL locking mode.

LockingWait

enum class LockingWait

PostgreSQL wait strategy for locked records.

PgEnumType

class PgEnumType<C : Enum<C>> : SqlType<C>

SqlType implementation represents PostgreSQL enum type.

PostgreSqlAssignmentsBuilder

open class PostgreSqlAssignmentsBuilder : AssignmentsBuilder

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

PostgreSqlDialect

open class PostgreSqlDialect : SqlDialect

SqlDialect implementation for PostgreSQL database.

PostgreSqlExpressionVisitor

open class PostgreSqlExpressionVisitor : SqlExpressionVisitor

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

PostgreSqlFormatter

open class PostgreSqlFormatter : SqlFormatter

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

TextArraySqlType

object TextArraySqlType : SqlType<TextArray>

SqlType implementation represents PostgreSQL text[] type.

Type Aliases

NameSummary

HStore

typealias HStore = Map<String, String?>

Represent values of PostgreSQL hstore SQL type.

TextArray

typealias TextArray = Array<String?>

Represent values of PostgreSQL text[] SQL type.

Functions

NameSummary

bulkInsert

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

Bulk insert records to the table and return the effected row count.

fun <T : BaseTable<*>> T.bulkInsert(
    block: BulkInsertStatementBuilder<T>.(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>.(T) -> Unit
): Int

fun <T : BaseTable<*>> T.bulkInsertOrUpdate(
    block: BulkInsertOrUpdateStatementBuilder<T>.(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.

bulkInsertOrUpdateReturning

fun <T : BaseTable<*>, C : Any> Database.bulkInsertOrUpdateReturning(
    table: T,
    returning: Column<C>,
    block: BulkInsertOrUpdateStatementBuilder<T>.(T) -> Unit
): List<C?>

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

fun <T : BaseTable<*>, C1 : Any, C2 : Any> Database.bulkInsertOrUpdateReturning(
    table: T,
    returning: Pair<Column<C1>, Column<C2>>,
    block: BulkInsertOrUpdateStatementBuilder<T>.(T) -> Unit
): List<Pair<C1?, C2?>>

fun <T : BaseTable<*>, C1 : Any, C2 : Any, C3 : Any> Database.bulkInsertOrUpdateReturning(
    table: T,
    returning: Triple<Column<C1>, Column<C2>, Column<C3>>,
    block: BulkInsertOrUpdateStatementBuilder<T>.(T) -> Unit
): List<Triple<C1?, C2?, C3?>>

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

bulkInsertReturning

fun <T : BaseTable<*>, C : Any> Database.bulkInsertReturning(
    table: T,
    returning: Column<C>,
    block: BulkInsertStatementBuilder<T>.(T) -> Unit
): List<C?>

Bulk insert records to the table and return the specific column’s values.

fun <T : BaseTable<*>, C1 : Any, C2 : Any> Database.bulkInsertReturning(
    table: T,
    returning: Pair<Column<C1>, Column<C2>>,
    block: BulkInsertStatementBuilder<T>.(T) -> Unit
): List<Pair<C1?, C2?>>

fun <T : BaseTable<*>, C1 : Any, C2 : Any, C3 : Any> Database.bulkInsertReturning(
    table: T,
    returning: Triple<Column<C1>, Column<C2>, Column<C3>>,
    block: BulkInsertStatementBuilder<T>.(T) -> Unit
): List<Triple<C1?, C2?, C3?>>

Bulk insert records to the table and return the specific columns’ values.

containedIn


fun ColumnDeclaring<HStore>.containedIn(
    argument: HStore
): HStoreExpression<Boolean>

HStore contained in operator, translated to the <@ operator in PostgreSQL.

contains


fun ColumnDeclaring<HStore>.contains(
    argument: HStore
): HStoreExpression<Boolean>

HStore contains operator, translated to the @> operator in PostgreSQL.

containsAll


fun ColumnDeclaring<HStore>.containsAll(
    argument: TextArray
): HStoreExpression<Boolean>

HStore contains all keys operator, translated to the ?& operator in PostgreSQL.

containsAny


fun ColumnDeclaring<HStore>.containsAny(
    argument: TextArray
): HStoreExpression<Boolean>

HStore contains any keys operator, translated to the ?| operator in PostgreSQL.

containsKey


fun ColumnDeclaring<HStore>.containsKey(
    argument: String
): HStoreExpression<Boolean>

HStore contains key operator, translated to the ? operator in PostgreSQL.

get


operator fun ColumnDeclaring<HStore>.get(
    argument: String
): HStoreExpression<String>

HStore get value for key operator, translated to the -> operator in PostgreSQL.


operator fun ColumnDeclaring<HStore>.get(
    argument: TextArray
): HStoreExpression<TextArray>

HStore get values for keys operator, translated to the -> operator in PostgreSQL.

hstore

fun <E : Any> BaseTable<E>.hstore(
    name: String
): Column<HStore>

Define a column typed HStoreSqlType.

ilike

infix fun ColumnDeclaring<*>.ilike(
    expr: ColumnDeclaring<String>
): ILikeExpression

infix fun ColumnDeclaring<*>.ilike(
    argument: String
): ILikeExpression

ILike operator, translated to the ilike keyword in PostgreSQL.

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.

insertOrUpdateReturning

fun <T : BaseTable<*>, C : Any> Database.insertOrUpdateReturning(
    table: T,
    returning: Column<C>,
    block: InsertOrUpdateStatementBuilder.(T) -> Unit
): C?

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

fun <T : BaseTable<*>, C1 : Any, C2 : Any> Database.insertOrUpdateReturning(
    table: T,
    returning: Pair<Column<C1>, Column<C2>>,
    block: InsertOrUpdateStatementBuilder.(T) -> Unit
): Pair<C1?, C2?>

fun <T : BaseTable<*>, C1 : Any, C2 : Any, C3 : Any> Database.insertOrUpdateReturning(
    table: T,
    returning: Triple<Column<C1>, Column<C2>, Column<C3>>,
    block: InsertOrUpdateStatementBuilder.(T) -> Unit
): Triple<C1?, C2?, C3?>

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

insertReturning

fun <T : BaseTable<*>, C : Any> Database.insertReturning(
    table: T,
    returning: Column<C>,
    block: AssignmentsBuilder.(T) -> Unit
): C?

Insert a record to the table and return the specific column.

fun <T : BaseTable<*>, C1 : Any, C2 : Any> Database.insertReturning(
    table: T,
    returning: Pair<Column<C1>, Column<C2>>,
    block: AssignmentsBuilder.(T) -> Unit
): Pair<C1?, C2?>

fun <T : BaseTable<*>, C1 : Any, C2 : Any, C3 : Any> Database.insertReturning(
    table: T,
    returning: Triple<Column<C1>, Column<C2>, Column<C3>>,
    block: AssignmentsBuilder.(T) -> Unit
): Triple<C1?, C2?, C3?>

Insert a record to the table and return the specific columns.

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:

minus

operator fun ColumnDeclaring<HStore>.minus(
    expr: ColumnDeclaring<String>
): HStoreExpression<HStore>

operator fun ColumnDeclaring<HStore>.minus(
    argument: String
): HStoreExpression<HStore>

HStore delete key operator, translated to the - operator in PostgreSQL.


operator fun ColumnDeclaring<HStore>.minus(
    argument: TextArray
): HStoreExpression<HStore>

HStore delete keys operator, translated to the - operator in PostgreSQL.

operator fun ColumnDeclaring<HStore>.minus(
    expr: ColumnDeclaring<HStore>
): HStoreExpression<HStore>

operator fun ColumnDeclaring<HStore>.minus(
    argument: HStore
): HStoreExpression<HStore>

HStore delete matching pairs operator, translated to the - operator in PostgreSQL.

pgEnum

fun <C : Enum<C>> BaseTable<*>.pgEnum(
    name: String
): Column<C>

Define a column typed of PgEnumType.
!Note Enums are case sensitive and must match what is in the db

plus

operator fun ColumnDeclaring<HStore>.plus(
    expr: ColumnDeclaring<HStore>
): HStoreExpression<HStore>

operator fun ColumnDeclaring<HStore>.plus(
    argument: HStore
): HStoreExpression<HStore>

HStore concatenate operator, translated to the || operator in PostgreSQL.

textArray

fun <E : Any> BaseTable<E>.textArray(
    name: String
): Column<TextArray>

Define a column typed TextArraySqlType.