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.
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.