Skip to content

Instantly share code, notes, and snippets.

View romainbsl's full-sized avatar

Romain Boisselle romainbsl

View GitHub Profile
import org.kodein.di.DirectDIAware
import org.kodein.di.instance
/**
* Auto resolve a class dependencies by using its constructor reference.
* The resolution is done at compile time by leveraging inline functions, no reflection is required.
*
* Example:
* ```
* val myModule = DI.module("myModule") {
@SalomonBrys
SalomonBrys / CTE.kt
Last active October 24, 2025 15:53
/*
Author: Salomon BRYS
License: MIT (do whatever you want with that code!)
Allows using Common Table Expressions with Jetbrains Exposed JDBC.
Provides primitives that implement CTEs, and a DSL that allows simpler usage.
Inspired by https://github.com/bog-walk/bootrack/blob/main/backend-jdbc/src/main/kotlin/dev/bogwalk/bootrack/backend/repository/custom/WithCTE.kt
/!\ Because the result rows of a CTE are referencing the With temporary table(s) fields and not the original query
table(s) fields, the results in a ResultRow are not easily accessible: you need to use either CTETable.get or wrap a