honeysql

lukasz 2023-08-18T22:10:00.357229Z

Might be a long shot, but worth trying: I made a mistake and used inline parameters in my queries, now I'm realizing that using :params is the way to go - did anyone run into this and wrote code to convert existing queries to parametrized ones? Probably doesn't even need rewrite-clj. Thanks!

Raghav 2023-08-20T19:06:33.363489Z

is there any sort of benifit in inlining the input instead of just passing it?

lukasz 2023-08-20T22:31:54.308549Z

Small benefit for me is that all my queries ignore records that are marked as deleted, and there's no way to override that - so inlining boolean conditions guarantees that

seancorfield 2023-08-18T22:12:28.259749Z

Can you explain the "mistake" in a bit more detail? When I hear "inline" and "mistake", I think of :inline putting the values into the SQL string. But I don't think that's what you mean?

seancorfield 2023-08-18T22:13:53.627929Z

The only reason I can think of that you might prefer :params over values in the DSL is for caching purposes (but I don't think many people use the caching system because of the restrictions it places on IN and ARRAY etc).

seancorfield 2023-08-18T22:15:05.442089Z

FWIW, I've never used named parameters with HoneySQL in my own code.

lukasz 2023-08-18T22:27:46.799339Z

For one, I cannot use caches, other part is that after experimenting a bit I found it easier to compose queries from bigger re-usable bits when parameters were involved. The last bit is because I have to work with JSONB there's a lot of :inline all over the place that I can avoid if I switch to named parameters

seancorfield 2023-08-18T22:29:26.078199Z

Hmm... :inline? Why? Wouldn't you use :lift to wrap JSON-like data inside the DSL? I'm curious about the use case to see if I can make it easier...?

lukasz 2023-08-18T22:32:05.882369Z

ah sorry, I meant :lift (it's been a long day) , but yes - I do have a lot of :inline too (for example when querying for boolean fields [:= :u.deleted [:inline false]] or constructing objects from sub-queries/joins [:json_build_object [:inline "id"] :u.id] )

lukasz 2023-08-18T22:33:28.384799Z

but named parameters won't help here anyway