hugsql

erwinrooijakkers 2023-11-22T12:20:45.921959Z

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

erwinrooijakkers 2023-11-22T12:21:03.813069Z

:? :1 syntax returns a map

erwinrooijakkers 2023-11-22T12:23:42.011269Z

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

erwinrooijakkers 2023-11-22T15:43:21.334779Z

not according to the documentation

erwinrooijakkers 2023-11-22T15:45:04.416529Z

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

curtis.summers 2023-11-22T22:55:16.184679Z

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
erwinrooijakkers 2023-11-27T13:10:27.476109Z

thanks!