hugsql 2023-11-22

is there a way to get a scalar value from HugSQL?

:? :1 syntax returns a map

-- :name select :? :1 SELECT MAX(foo) FROM bar; returns {: 1} . I want to return the value directly. (I do know I can use SELECT MAX(foo) AS foo FROM bar; to change the keyword to :foo, but wonder if I can return the 1 only.)

not according to the documentation

could add a new function to the hugsql.adapter interface maybe, :scalar or so for result-scalar

You can create your own result function by implementing a hugsql.core/hugsql-result-fn multimethod. https://www.hugsql.org/hugsql-in-detail/result You do not need to add anything to the adapter.

1

thanks!