hugsql

Merveille van Eck 2025-05-25T18:06:12.932039Z

this is totally left field but ive been working with loads of hugsql based http APIs, is there anything nice out there for generating malli schemas from hugsql files? would be an absolute bomb for validation in endpoints

lukasz 2025-05-25T18:28:02.181969Z

I was thinking about this when working with hugsql back in the day (Malli wasn't a thing yet, we used Prismatic Schema) and I think there was something in hugsql's internals that can tell you all named inputs, from there you should be able to generate some simple schemas

Merveille van Eck 2025-05-25T18:29:09.798089Z

this would be so awesome. probably going to see if i can get my team to put something together that can be reused when working with hug

lukasz 2025-05-25T18:29:47.933499Z

FWIW stuff like that made us move to HoneySQL, it's much easier to reason about your query inputs

lukasz 2025-05-25T18:29:56.916179Z

and composing queries in general

Merveille van Eck 2025-05-25T18:30:36.546459Z

maybe something like an importable namespace that also requires hug from which one can grab a function / macro that uses the hugsql situation to def the schemas

Merveille van Eck 2025-05-25T18:30:50.788309Z

is it easier to interop with malli when using honey?

lukasz 2025-05-25T18:34:53.123069Z

depends on what you mean by interop - since queries are represented as data you'll have an easier time validating inputs to your query builder, or what comes out of it e.g. validate that every query generated by all functions contains a tenant_id condition in :where clause, stuff like that

Merveille van Eck 2025-06-04T19:32:39.356689Z

after having fiddled with hugsql and setting up migrations. you have me convinced @lukaszkorecki honey just feels more idiomatic, and its not really that far from standard sql.

lukasz 2025-06-04T19:48:53.070429Z

happy to hear that, don’t get me wrong - I used HugSQL in anger and I do like it, but only for very specific use cases, HoneySQL just has better dev ergonomics and scales better with complexity

Merveille van Eck 2025-06-04T19:51:45.765219Z

thats the thing. its the scaling that makes it so damn good. for a very trivial sql use case, hug is fine. but for most cases where one really wants to rely on the data model for creating a great user experience, one ends up wanting more. i think i will try to do my next project using hug and compare fully the experience of it

👍 1