Exposed icon indicating copy to clipboard operation
Exposed copied to clipboard

Support DESC INDEX

Open MC-XiaoHei opened this issue 10 months ago • 2 comments

It would be great to be able to do something like this with an API

CREATE INDEX IF NOT EXISTS unit_operations_time_idx ON unit_operations (time DESC);

for now, I need to use some code like this to implement this:

object UnitOperationsTable : LongIdTable("unit_operations") {
    val unitId = integer("unit_id")
    val time = defaultNowTimestampTz("time")

    init {
        index(customIndexName = "unit_operations_unit_id_idx", columns = arrayOf(unitId))
        try {
            transaction {
                exec("CREATE INDEX IF NOT EXISTS unit_operations_time_idx ON unit_operations (time DESC);")
            }
        } catch (_: ExposedSQLException) {
            // when run first time, the table may not exist, so ignore the error
        }
    }
}

and you see, index wil not created at the first time. I'd like some other alternative way to do this

MC-XiaoHei avatar Feb 19 '25 14:02 MC-XiaoHei

Can I Work on it?

AminaHasanaath avatar Jun 24 '25 15:06 AminaHasanaath

Is it needed? Most RDBMS can read an index backwards.

mattbdc avatar Sep 25 '25 01:09 mattbdc