Fork me on GitHub

I have formatted the DSL with sql/format. Now given the vector, is it convert it to the normal sql string as if I have formatted with the inline true firsthand?


@i I don't understand your question - can you provide a small example?


(-> (select :tb)
the above gives a vector based representation. Given the above result, I want to have the inline form, as if I have used (sql/format :inline) initially.


Why not just use (sql/format :inline true) then?


(and this is a question for #honeysql not #sql really)


Also be aware that using :inline formatting can open you up to SQL injection attacks so it's not something you generally want to do in production code.


> Why not just use `(sql/format :inline true)` then? The function is written without :inline. But sometimes for convenience I’d like to copy-paste the result in a inline form and instead of vector form to the sql console.


Then refactor the code. Split that function into one that just builds the data structure and call that from the current function with (sql/format) as-is. Then you can call that new function and wrap it in (sql/format :inline true) when you want the inline result for your SQL console.


Or add an optional argument that lets you invoke the original function with the :inline flag passed in.


(although I'd be wary of encouraging other users of that code to produce inline-formatted SQL because of the injection potential)


TIL about the inline option!