Exposed
CLAUDE.md9.3k starsChanged 8 months agoApache-2.0View on GitHub
Exposed is a lightweight ORM framework for Kotlin that provides two APIs: - DSL API: Type-safe SQL-wrapping Domain Specific Language (in exposed-core) - Works with both JDBC (exposed-jdbc) and R2DBC (exposed-r2dbc) - DAO API: Lightweight Data Access Object API (in exposed-dao) - Only works with JDBC - does not support R2DBC Tests are organized by database and dialect. Each module has database-specific test tasks: Tests inherit from different base classes depending on the driver: JDBC Tests - inherit from DatabaseTestsBase…
Trending
More talk lately.about the whole repository
Who's talking about JetBrains/Exposed
- prisma/orm“Kotlin client”GitHub · Feb 21, 2022 · 66 reactions
- r2dbc/r2dbc-spi“Expose database/schema metadata through Connection”GitHub · Mar 13, 2021 · 43 reactions
- Tapac/exposed-wiki“Updated date/time data types and added reference to `exposed-java-time`”GitHub · May 17, 2021 · 3 reactions
- Velkonost/sssss“deps(gradle): bump exposed from 0.54.0 to 0.61.0”GitHub · Oct 15, 2025 · 2 reactions
- flyway/flyway“Would it be possible to use flyway to compare two database schemas and upgrade one's schema to match the …”GitHub · Feb 7, 2020 · 2 reactions
The biggest 5 of 34 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 34
Talked about on GitHub (34 times).
On GitHub · 34
- Feb 21, 2022Kotlin client — prisma/orm66 reactions · 1 comment
- Mar 13, 2021Expose database/schema metadata through Connection — r2dbc/r2dbc-spi43 reactions · 2 comments
- May 17, 2021Updated date/time data types and added reference to `exposed-java-time` — Tapac/exposed-wiki3 reactions · 1 comment
- Oct 15, 2025deps(gradle): bump exposed from 0.54.0 to 0.61.0 — Velkonost/sssss2 reactions · 1 comment
- Feb 7, 2020Would it be possible to use flyway to compare two database schemas and upgrade one's schema to match the other? — flyway/flyway2 reactions · 4 comments
29 more on GitHub
- Aug 31, 2026Bump exposed from 1.2.0 to 1.5.0 — peco2282/DevCore1 reaction · 1 comment
- Aug 10, 2026Bump exposed from 1.2.0 to 1.4.0 — peco2282/DevCore1 reaction · 2 comments
- Jul 5, 2026Bump exposed from 1.2.0 to 1.3.1 — peco2282/DevCore1 reaction · 2 comments
- Jul 1, 2026Bump org.jetbrains.exposed:exposed-core from 1.2.0 to 1.3.1 — peco2282/DevCore1 reaction · 2 comments
- Jul 1, 2026Bump org.jetbrains.exposed:exposed-jdbc from 1.2.0 to 1.3.1 — peco2282/DevCore1 reaction · 2 comments
- Jul 1, 2026Bump org.jetbrains.exposed:exposed-java-time from 1.2.0 to 1.3.1 — peco2282/DevCore1 reaction · 2 comments
- Sep 22, 2025deps(deps): bump exposed from 0.58.0 to 0.61.0 — JetBrains/koog1 reaction · 2 comments
- May 9, 2024deps: update exposed to v0.50.1 — oss-review-toolkit/ort1 reaction · 1 comment
- Mar 2, 2023Setup DB migration — digitalfabrik/entitlementcard1 reaction
- Sep 28, 2022NonBooleanPropertyPrefixedWithIs is catching quasi-boolean properties — detekt/detekt1 reaction · 8 comments
- Aug 3, 2019Add support for transaction by method + lambda — micronaut-projects/micronaut-data1 reaction · 4 comments
- Jul 20, 2018kotlin: exposed module — jooby-project/jooby1 reaction
- Oct 3, 2026⬆️ Bump the "dependencies" group with 1 update across multiple ecosystems — navikt/helse-spinnvill0 reactions
- Oct 1, 2026chore(deps): bump exposed from 0.49.0 to 1.5.0 in /reposilite-backend — zast-cve-benchmark/reposilite-3.5.110 reactions
- Sep 27, 2026build(deps): bump exposedVersion from 1.4.0 to 1.5.0 — jnoecker/AmbonMUD0 reactions
- Sep 24, 2026build(deps): bump exposedVersion from 0.46.0 to 1.5.0 in /server — xalor888/Maodouchat0 reactions · 1 comment
- Sep 24, 2026chore(deps): bump the dependencies group across 1 directory with 12 updates — navikt/tsm-pdl-cache0 reactions
- Sep 23, 2026Bump exposedVersion from 0.57.0 to 1.5.0 — Olexandr1904/mono-category0 reactions · 1 comment
- Sep 19, 2026chore(deps): bump exposed from 1.1.1 to 1.5.0 — coreyh-nz/risktionary-backend0 reactions
- Sep 11, 2026Bump exposed from 0.61.0 to 1.5.0 — grepsedawk/CivDiscord0 reactions
- Sep 7, 2026Bump exposed from 1.4.0 to 1.5.0 — navikt/nks-bob-api0 reactions
- Aug 31, 2026Bump exposed from 1.4.0 to 1.5.0 — alad1nks/jaiqal0 reactions
- Aug 30, 2026build(deps): bump org.jetbrains.exposed:exposed-jdbc from 0.50.1 to 1.5.0 — cyrus07424/openDroneDiary0 reactions
- May 14, 2026Bump org.jetbrains.exposed:exposed-java-time from 1.2.0 to 1.3.0 — peco2282/DevCore0 reactions · 2 comments
- May 14, 2026Bump org.jetbrains.exposed:exposed-core from 1.2.0 to 1.3.0 — peco2282/DevCore0 reactions · 2 comments
- May 14, 2026Bump org.jetbrains.exposed:exposed-jdbc from 1.2.0 to 1.3.0 — peco2282/DevCore0 reactions · 2 comments
- Apr 7, 2026Bump org.jetbrains.exposed:exposed-core from 1.0.0 to 1.2.0 — peco2282/DevCore0 reactions · 2 comments
- Apr 7, 2026Bump org.jetbrains.exposed:exposed-java-time from 1.0.0 to 1.2.0 — peco2282/DevCore0 reactions · 2 comments
- Apr 7, 2026Bump org.jetbrains.exposed:exposed-jdbc from 1.0.0 to 1.2.0 — peco2282/DevCore0 reactions · 2 comments
In this repository2 other files it gives its agents.
- fix-bugSkill
- migrate-to-1.0Skill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
19 rules. About 0 are common, 6 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Only works with JDBC: - does not support R2DBC
- Very specific: line 111
Test methods use = runTest { } for coroutine support, or utils methods like withDb, withTables,
- Distinctive: line 120
Before/after connection hooks
- Distinctive: line 197
Never mix JDBC and R2DBC transaction functions
- Very specific: line 208
Create column type class in exposed-core (extends ColumnType)
- Very specific: line 209
Add factory method to Table class
- Very specific: line 210
Add dialect-specific SQL type mapping in DataTypeProvider implementations
- Very specific: line 211
Add tests in exposed-tests covering multiple databases
- Distinctive: line 223
Always test features against multiple databases, especially H2, PostgreSQL, and MySQL
- Distinctive: line 224
Use dialect checks when implementing database-specific features:
- Very specific: line 234
Use Assumptions.assumeTrue() or excludeSettings argument in withTables to skip tests for unsupported databases
- Very specific: line 235
Prefer withTables over manual SchemaUtils.create/drop for cleaner tests
- Distinctive: line 236
Test both JDBC and R2DBC implementations when adding core features
- Very specific: line 237
Use currentDialectTest to access current dialect in assertions
- Very specific: line 240
Run ./gradlew apiCheck before committing public API changes
- Very specific: line 242
Use @InternalApi annotation for internal implementation details
- Very specific: line 243
Document breaking changes in BREAKING_CHANGES.md under "Breaking changes" section
- Very specific: line 265
Test classes: Suffix with Tests or Test
- Very specific: line 266
Test methods: Descriptive names starting with test
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
Exposed is a lightweight ORM framework for Kotlin that provides two APIs:
- DSL API: Type-safe SQL-wrapping Domain Specific Language (in
exposed-core)- Works with both JDBC (
exposed-jdbc) and R2DBC (exposed-r2dbc)
- Works with both JDBC (
- DAO API: Lightweight Data Access Object API (in
exposed-dao)- Only works with JDBC - does not support R2DBC
Module Architecture
Core Modules
- exposed-core: Foundation layer with DSL API, database abstractions, column types, and vendor dialects
- exposed-dao: DAO API with entity classes and relationships (JDBC only, does not work with R2DBC)
- exposed-jdbc: JDBC implementation with blocking transactions
- exposed-r2dbc: R2DBC implementation with suspending transactions
Extension Modules
- exposed-java-time, exposed-jodatime, exposed-kotlin-datetime: Date/time support
- exposed-json: JSON/JSONB column types
- exposed-crypt: Encrypted column types
- exposed-money: JavaMoney MonetaryAmount support
- exposed-migration-core: Common migration functionality
- exposed-migration-jdbc: JDBC-based schema migrations
- exposed-migration-r2dbc: R2DBC-based schema migrations
- exposed-spring-boot-starter: Spring Boot integration
- spring-transaction: Spring Framework transaction manager
Test Modules
- exposed-tests: Main JDBC-based test suite
- exposed-r2dbc-tests: R2DBC-specific test suite
- exposed-jdbc-r2dbc-tests: Cross-compatibility tests
Build & Development
Building
./gradlew compileKotlin # Compile the projects code
./gradlew detekt # Validate code style
./gradlew apiDump # Update dokka API docs after changing public APIRunning Tests
Tests are organized by database and dialect. Each module has database-specific test tasks:
Quick test with H2 (no Docker required)
./gradlew test_h2_v2 # All modules with H2
./gradlew :exposed-tests:test_h2_v2 # JDBC Tests with H2
./gradlew :exposed-r2dbc-tests:test_h2_v2 # R2DBC Tests with H2Test with Postgres
./gradlew test_postgres # All modules with Postgres
./gradlew :exposed-tests:test_postgres # JDBC Tests with Postgres
./gradlew :exposed-r2dbc-tests:test_postgres # R2DBC Tests with PostgresTest with specific database (requires Docker)
# Start database containers first
./gradlew mariadbComposeUp # Start MariaDB
./gradlew postgresComposeUp # Start PostgreSQL
./gradlew mysql8ComposeUp # Start MySQL 8
./gradlew oracleComposeUp # Start Oracle
./gradlew sqlserverComposeUp # Start SQL Server
# Run tests
./gradlew :exposed-tests:test_postgres
./gradlew :exposed-tests:test_mysql_v8
./gradlew :exposed-tests:test_mariadb
# Stop containers
./gradlew postgresComposeDownForcedRun specific test class or method with H2
./gradlew :exposed-tests:test_h2_v2 --tests "org.jetbrains.exposed.v1.tests.shared.dml.InsertTests"
./gradlew :exposed-tests:test_h2_v2 --tests "*.InsertTests.testBatchInsert"Available test databases
test_h2_v2,test_h2_v2_mysql,test_h2_v2_psql, etc. (H2 with different dialect emulations)test_sqlitetest_mysql_v5,test_mysql_v8test_mariadbtest_postgres,test_postgresngtest_oracletest_sqlserver
Testing Infrastructure
Test Base Classes and Utilities
Tests inherit from different base classes depending on the driver:
JDBC Tests - inherit from DatabaseTestsBase (in exposed-tests/src/main/kotlin/org/jetbrains/exposed/v1/tests/):
- Tests are parameterized by database dialect using
@ParameterizedClassand@MethodSource("data") - Each test automatically runs against all enabled dialects
- Available dialects are determined by system properties set by Gradle test tasks
R2DBC Tests - inherit from R2dbcDatabaseTestsBase (in exposed-r2dbc-tests/src/main/kotlin/):
- Similar parameterized testing pattern as JDBC
- Uses suspending functions and coroutine context
- Test methods use
= runTest { }for coroutine support, or utils methods likewithDb,withTables,
TestDB Enums
There are separate TestDB enums for JDBC and R2DBC tests:
JDBC TestDB (exposed-tests/src/main/kotlin/org/jetbrains/exposed/v1/tests/TestDB.kt):
- Connection strings using JDBC URLs (e.g.,
jdbc:h2:mem:...,jdbc:postgresql://...) - JDBC driver class names
- Before/after connection hooks
- Database-specific configuration (e.g., H2 dialect emulation modes)
Available JDBC TestDB values:
H2_V2,H2_V2_MYSQL,H2_V2_PSQL,H2_V2_MARIADB,H2_V2_ORACLE,H2_V2_SQLSERVERSQLITE,MYSQL_V5,MYSQL_V8,MARIADB,POSTGRESQL,POSTGRESQLNG,ORACLE,SQLSERVER
R2DBC TestDB (exposed-r2dbc-tests/src/main/kotlin/org/jetbrains/exposed/v1/r2dbc/tests/TestDB.kt):
- Connection strings using R2DBC URLs (e.g.,
r2dbc:h2:mem:...,r2dbc:postgresql://...) - R2DBC isolation levels
- Suspend-aware before/after connection hooks
Available R2DBC TestDB values:
H2_V2,H2_V2_MYSQL,H2_V2_PSQL,H2_V2_MARIADB,H2_V2_ORACLE,H2_V2_SQLSERVERMYSQL_V5,MYSQL_V8,MARIADB,POSTGRESQL,ORACLE,SQLSERVER- Note: R2DBC does not support
SQLITEorPOSTGRESQLNG
Writing Tests
Tests extend DatabaseTestsBase and use these helper functions:
JDBC Tests with withDb
class MyTests : DatabaseTestsBase() {
@Test
fun testSomething() {
withDb { testDb -> // Runs against current dialect
// Create tables
SchemaUtils.create(MyTable)
// Insert/query data
MyTable.insert { it[name] = "test" }
// Clean up
SchemaUtils.drop(MyTable)
}
}
}Using withTables for automatic table management
@Test
fun testWithTables() {
withTables(MyTable, AnotherTable) {
// Tables are created before block and dropped after
MyTable.insert { it[name] = "test" }
}
}Conditional tests
@Test
fun testPostgresOnly() {
withDb(TestDB.POSTGRESQL) { // Only runs for PostgreSQL
// Postgres-specific test
}
}Skip databases that don't support a feature
@Test
fun testJsonSupport() {
withTables(JsonTable, excludeSettings = listOf(TestDB.SQLITE, TestDB.MYSQL_V5)) {
// Test JSON columns
}
}Important Patterns
Transaction Context
- JDBC:
transaction { }- blocking transaction execution - JDBC:
suspendTransaction { }- suspending, with actually blocking database connections - R2DBC:
suspendTransaction { }- suspending, uses coroutine context - Never mix JDBC and R2DBC transaction functions
Database Vendor Support
Database-specific behavior is in exposed-core/src/main/kotlin/org/jetbrains/exposed/v1/core/vendors/:
H2.kt,MysqlDialect.kt,PostgreSQL.kt,OracleDialect.kt,SQLServerDialect.kt,SQLiteDialect.kt,MariaDBDialect.kt- Extend
DatabaseDialectand implementVendorDialect - Override
DataTypeProviderandFunctionProviderfor dialect-specific SQL
Common Development Tasks
Adding a new column type
- Create column type class in
exposed-core(extendsColumnType) - Add factory method to
Tableclass - Add dialect-specific SQL type mapping in
DataTypeProviderimplementations - Add tests in
exposed-testscovering multiple databases - Add tests in
exposed-r2dbc-testscovering multiple databases
Working with migrations
- Migration modules use serialization to track schema state
- JDBC migrations:
exposed-migration-jdbcwithMigrationUtils - R2DBC migrations:
exposed-migration-r2dbcwith suspend support - Both share common code from
exposed-migration-core
Best Practices and Gotchas
Multi-Database Compatibility
- Always test features against multiple databases, especially H2, PostgreSQL, and MySQL
- Use dialect checks when implementing database-specific features:
if (currentDialectTest is PostgreSQLDialect) { // PostgreSQL-specific code } - H2 dialect emulation modes (
H2_V2_MYSQL,H2_V2_PSQL, etc.) help catch compatibility issues early
Testing Best Practices
- Extend
DatabaseTestsBaseorR2dbcDatabaseTestsBasefor parameterized multi-database testing - Use
Assumptions.assumeTrue()orexcludeSettingsargument inwithTablesto skip tests for unsupported databases - Prefer
withTablesover manualSchemaUtils.create/dropfor cleaner tests - Test both JDBC and R2DBC implementations when adding core features
- Use
currentDialectTestto access current dialect in assertions
API Compatibility
- Run
./gradlew apiCheckbefore committing public API changes - Binary compatibility is critical - breaking changes require major version bump
- Use
@InternalApiannotation for internal implementation details - Document breaking changes in BREAKING_CHANGES.md under "Breaking changes" section
Code Style and Conventions
Style Configuration
- EditorConfig:
.editorconfigdefines code formatting rules- Indent: 4 spaces
- Max line length: 166 characters
- Charset: UTF-8
- End of line: LF
- Kotlin code style: KOTLIN_OFFICIAL
- Detekt: Static analysis with
detekt/detekt-config.yml- Max issues: 0 (all issues must be fixed)
- Wildcard imports are allowed
- Magic numbers allowed in named arguments and ranges
- Run with:
./gradlew detekt
Naming Conventions
- Package structure uses
org.jetbrains.exposed.v1.*namespace - Table objects: PascalCase (e.g.,
Users,Cities) - Column names: camelCase in code, snake_case in SQL
- Test classes: Suffix with
TestsorTest - Test methods: Descriptive names starting with
test
Common Utilities
Located in exposed-tests/src/main/kotlin/org/jetbrains/exposed/v1/tests/:
TestUtils.kt:currentDialectTest,currentDialectMetadataTest, helper functionsDatabaseTestsBase.kt: Base class for all JDBC testsR2DBCDatabaseTestsBase.kt: Base class for all R2DBC testsTestDB.kt: Database connection configurationsshared/Assert.kt: Custom assertion functionsshared/MiscTable.kt,shared/ForeignKeyTables.kt: Reusable test tables
Sample Projects
The samples/ directory contains reference implementations:
- exposed-ktor: Ktor application with JDBC
- exposed-ktor-r2dbc: Ktor application with R2DBC
- exposed-migration: Migration examples
- exposed-spring: Spring Boot integration examples
These demonstrate best practices for using Exposed in real applications.
Key Files
buildSrc/: Custom Gradle plugins and build configurationbuild.gradle.kts: Root build configuration with testDb DSL usagesettings.gradle.kts: Module definitionsbuildScripts/docker/: Database container configurationsgradle.properties: Version and build settings.editorconfig: Code formatting rulesdetekt/detekt-config.yml: Static analysis configuration
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

