If I execute a raw query using the snippet I found...
# exposed
d
If I execute a raw query using the snippet I found on the issue tracker below, how can I turn a ResultSet into a SizedIterable<ResultRow> that I can wrap an Entity in? In essence, I want to be able to call #wrapRows.
Copy code
fun Transaction.exec(sql: String, body: PreparedStatementApi.() -> Unit) : ResultSet? {
    return connection.prepareStatement(sql, true).apply(body).run {
        if (sql.toLowerCase().startsWith("select "))
            executeQuery()
        else {
            executeUpdate()
            resultSet
        }
    }
}
I saw usage of ResultRow.create(ResultSet, Map<Expression, Int>), and it provided Entity#fields to Map<Expression, Int>, but Entity#fields is a List<Expression> instead of a Map to Int. Furthermore, it seems this method uses the index in the result row instead of the name (hinted from GitHub's source of ResultRow#create), which seems risky? Really need to perform a handful of complex queries and still access it as an object to construct a DTO.
j
I think when running raw sql queries the onus is on the user to keep track of which column contains a particular piece of data. Accessing by column index seems to be the intended way of working with
ResultSet
.
The ResultRow accessor is also just mapping a column to an index for this lookup I think.