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.

Cube

data class Cube

Represents a box suitable for an indexed search using the cube @> operator.
Part of PostgreSQL cube SQL extension.
https://www.postgresql.org/docs/9.5/cube.html

CubeExpression

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

Expression class represents PostgreSQL Cube operations.

CubeExpressionType

enum class CubeExpressionType

Enum for ‘cube’ and ‘earthdistance’ binary operators.

CubeSqlType

object CubeSqlType : SqlType<Cube>

Represents a Cube by storing 2 n-dimensional points
Part of PostgreSQL cube SQL extension.
https://www.postgresql.org/docs/9.5/cube.html

DefaultValueExpression

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

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

EarthSqlType

object EarthSqlType : SqlType<Earth>

Cube-based earth abstraction, using 3 coordinates representing the x, y, and z distance from the center of the Earth.
Part of PostgreSQL earthdistance SQL extension.

HStoreExpression

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

Expression class represents PostgreSQL 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 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.

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

interface PostgreSqlExpressionVisitor : SqlExpressionVisitor

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

PostgreSqlFormatter

open class PostgreSqlFormatter : 
    SqlFormatter,
    PostgreSqlExpressionVisitor

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

Earth

typealias Earth = Triple<Double, Double, Double>

Cube-based earth abstraction, using 3 coordinates representing the x, y, and z distance from the center of the Earth.
Part of PostgreSQL earthdistance extension.
https://www.postgresql.org/docs/12/earthdistance.html

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<Cube>.containedIn(
    expr: ColumnDeclaring<Cube>
): CubeExpression<Boolean>

fun ColumnDeclaring<Cube>.containedIn(
    argument: Cube
): CubeExpression<Boolean>

fun ColumnDeclaring<Earth>.containedIn(
    expr: ColumnDeclaring<Cube>
): CubeExpression<Boolean>

fun ColumnDeclaring<Earth>.containedIn(
    argument: Cube
): CubeExpression<Boolean>

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


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

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

contains


fun ColumnDeclaring<Cube>.contains(
    argument: Cube
): CubeExpression<Boolean>


fun ColumnDeclaring<Cube>.contains(
    argument: Earth
): CubeExpression<Boolean>

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


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.

cube

fun BaseTable<*>.cube(name: String): Column<Cube>

Define a column typed CubeSqlType.

defaultValue

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

Return a default value for this column, see DefaultValueExpression.

earth

fun BaseTable<*>.earth(name: String): Column<Earth>

Define a column typed EarthSqlType.

earthBox

fun earthBox(
    point: ColumnDeclaring<Earth>,
    radius: ColumnDeclaring<Double>
): FunctionExpression<Cube>

fun earthBox(
    point: ColumnDeclaring<Earth>,
    radius: Double
): FunctionExpression<Cube>

fun earthBox(
    point: Earth,
    radius: ColumnDeclaring<Double>
): FunctionExpression<Cube>

fun earthBox(
    point: Earth,
    radius: Double
): FunctionExpression<Cube>

Returns a box suitable for an indexed search using the cube @> operator for points within a given great circle
distance of a location. Some points in this box are further than the specified great circle distance from the
location, so a second check using earth_distance should be included in the query.

earthDistance

fun earthDistance(
    p1: ColumnDeclaring<Earth>,
    p2: ColumnDeclaring<Earth>
): FunctionExpression<Double>

fun earthDistance(
    p1: ColumnDeclaring<Earth>,
    p2: Earth
): FunctionExpression<Double>

fun earthDistance(
    p1: Earth,
    p2: ColumnDeclaring<Earth>
): FunctionExpression<Double>

fun earthDistance(
    p1: Earth,
    p2: Earth
): FunctionExpression<Double>

Returns the great circle distance between two points on the surface of the Earth.

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

latitude

fun latitude(
    earth: ColumnDeclaring<Earth>
): FunctionExpression<Double>

fun latitude(earth: Earth): FunctionExpression<Double>

Returns the latitude in degrees of a point on the surface of the Earth.

llToEarth

fun llToEarth(
    lat: ColumnDeclaring<Double>,
    lng: ColumnDeclaring<Double>
): FunctionExpression<Earth>

fun llToEarth(
    lat: ColumnDeclaring<Double>,
    lng: Double
): FunctionExpression<Earth>

fun llToEarth(
    lat: Double,
    lng: ColumnDeclaring<Double>
): FunctionExpression<Earth>

fun llToEarth(
    lat: Double,
    lng: Double
): FunctionExpression<Earth>

Returns the location of a point on the surface of the Earth
given its latitude (argument 1) and longitude (argument 2) in degrees.

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:

longitude

fun longitude(
    earth: ColumnDeclaring<Earth>
): FunctionExpression<Double>

fun longitude(earth: Earth): FunctionExpression<Double>

Returns the longitude in degrees of a point on the surface of the Earth.

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.

overlaps


fun ColumnDeclaring<Cube>.overlaps(
    argument: Cube
): CubeExpression<Boolean>

Cube overlap operator, translated to the && operator in PostgreSQL.

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 BaseTable<*>.textArray(name: String): Column<TextArray>

Define a column typed TextArraySqlType.