| Metadata | Value |
|---|---|
| Status | Active |
| Version | 1.1.0 |
| Last Updated | 2026-09-10 |
| Author | Sangeetha Grantha Team |
| Document Type | Design reference |
[!NOTE] Design/reference material: this page may include proposals or earlier implementation assumptions. Use current feature map for implemented behavior and current operating steps.
This document tracks the testing and implementation of new Exposed 1.0.0 features in the Sangeetha Grantha codebase.
✅ Confirmed: Project is using Exposed 1.0.0 via version catalog:
gradle/libs.versions.toml: exposed = "1.0.0"insert().resultedValues ✅ IMPLEMENTEDLocation: modules/backend/dal/src/main/kotlin/com/sangita/grantha/backend/dal/repositories/UserRepository.kt
Implementation:
suspend fun create(...): UserDto = DatabaseFactory.dbQuery {
val now = OffsetDateTime.now(ZoneOffset.UTC)
val newId = UUID.randomUUID()
UsersTable
.insert {
it[id] = newId
it[UsersTable.email] = email
it[UsersTable.fullName] = fullName
// ... other fields
it[UsersTable.createdAt] = now
it[UsersTable.updatedAt] = now
}
.resultedValues
?.single()
?.toUserDto()
?: error("Failed to insert user")
}
Benefits:
Status: ✅ Working - Code compiles and follows Exposed 1.0.0 API
updateReturning ✅ IMPLEMENTEDLocation: All repository update methods across the codebase
Implementation:
suspend fun update(...): UserDto? = DatabaseFactory.dbQuery {
val now = OffsetDateTime.now(ZoneOffset.UTC)
val javaId = id.toJavaUuid()
// Use Exposed 1.0.0 updateReturning to update and fetch the row in one round-trip
UsersTable
.updateReturning(
where = { UsersTable.id eq javaId }
) {
email?.let { value -> it[UsersTable.email] = value }
fullName?.let { value -> it[UsersTable.fullName] = value }
// ... other fields
it[UsersTable.updatedAt] = now
}
.singleOrNull()
?.toUserDto()
}
API Confirmed:
Table.updateReturning(where = {...}, body = {...})Query that can be chained with .singleOrNull() or .map { }Benefits:
Status: ✅ Fully Implemented - All repository update methods now use updateReturning
Repositories Updated:
modules/backend/dal/src/test/kotlin/com/sangita/grantha/backend/dal/repositories/UserRepositoryTest.kt
create should return UserDto from resultedValues
resultedValues correctly populates all DTO fieldscreatedAt and updatedAt are set correctlycreate with minimal fields should work
update should return updated UserDto using updateReturning
updatedAt changes while createdAt remains unchangedupdate with partial fields should only update specified fields
update non-existent user should return null
findById should return created user
findById should return null for non-existent user
Database: H2 in-memory (PostgreSQL compatibility mode)
Dependencies Added:
testImplementation("com.h2database:h2:2.2.224")
testImplementation(libs.kotlinx.coroutines.test)
✅ Main Code: Compiles successfully
✅ Test Code: Compiles successfully (with minor deprecation warnings for kotlinx.datetime.Instant)
resultedValues in UserRepository.createresultedValuesupdateReturning API- ✅ Exposed 1.0.0 fully supports RETURNING clause via updateReturning and resultedValuesupdateReturning in UserRepository.updateresultedValues pattern to all repositories:
KrithiRepository.create, createLyricVariantComposerRepository.createRagaRepository.createTalaRepository.createTempleRepository.createTagRepository.createImportRepository.createImportKrithiNotationRepository.createVariant, createRowupdateReturning pattern to all repositories:
KrithiRepository.update, updateLyricVariantComposerRepository.updateRagaRepository.updateTalaRepository.updateTempleRepository.updateTagRepository.updateImportRepository.reviewImportKrithiNotationRepository.updateVariant, updateRowapplication_documentation/02-architecture/decisions/exposed-dsl-optimization-implementation.mdapplication_documentation/06-backend/query-optimization-evaluation.mdresultedValues feature works as expected and provides immediate performance benefitsupdateReturning API verified and fully implemented across all repositories