Fork me on GitHub

Hi there 🙂 is there a way to get the connection used to execute a query on hugsql.core/hugsql-result-fn ? i want to inject new data on the results after loaded, but i need to use the same db conenction (and don’t want to relay on a global connection)


@jmayaalv Hi. The hugsql-result-fn multimethod doesn't have access to the db connection, but the hugsql-command-fn does, as it calls either execute or query on the hugsql adapter. So, you could feasibly implement a custom hugsql-command-fn and then use the :raw (default) result. However, depending on what you're doing, since your user code calling a hugsql function already has access to the database connection, you might consider just wrapping the hugsql function in your own code that handles the additions you're wanting to make.


thanks a lot @curtis.summers this sounds exactly like what i need 🙂


@jmayaalv I'd recommend using a connection pool as the thing you pass around, rather than having the JDBC lib create entire new connections on demand. next.jdbc has built in support for c3p0 and HikariCP. accepts a {:connection pooled-datasource} db-spec, where the pooled-datasource is built from c3p0 or HikariCP