exposed-postgres-extensions
is a library that adds PostgreSQL-specific functionality to JetBrains' Exposed.
This library is in a very early state. Expect bugs and rough corners. Feel free to report any issues and submit PRs !
- Generated columns (
generated always as
) (see: PostgreSQL Docs) - Very basic support for
JSONB
- Additional functions (currently
String
:bit_length
,char_length
andoctet_length
) - Basic support of LISTEN / NOTIFY
Simply include the library with JitPack (Gradle Kotlin DSL) :
repositories {
maven("https://jitpack.io")
}
/* ... */
dependencies {
implementation("com.github.Benjozork:exposed-postgres-extensions:master-SNAPSHOT")
}
That's it ! No additional setup required.
Create a table with a generated column :
(note: PgTable
is currently needed to use the .generated {}
extension, because of limitation with Kotlin extension functions)
object : PgTable() {
val id = integer("id")
val name = text("name")
val uppercaseName = bool("name_is_short")
.generated { name.upperCase().charLength() less 10 }
override val primaryKey = PrimaryKey(id)
}
This will result in the following DDL (formatted for legibility reasons) :
create table if not exists test (
id int primary key,
"name" text not null,
name_is_short boolean
generated always as (
char_length(upper(test."name")) < 10
) stored not null
);