Hello there, I love honeysql
Is there a way to generate a query as a non-parameterized string ? Instead of
(sql/format sqlmap)
=> ["SELECT a, b, c FROM foo WHERE f.a = ?" "baz"]
I’d like to generate the following string
SELECT a, b, c FROM foo WHERE f.a = "baz"
The reason is that I’d like to be able to copy and paste the query into a SQL console
I found it!
user=> (sql/format sqlmap :parameterizer :none)
["SELECT a, b, c FROM foo WHERE f.a = baz"]
:party-corgi:
That doesn’t look quite right. Shouldn’t baz
be in single quotes?
@jkrasnay HoneySQL 1.0 does no conversion on parameters so the :none
parameterizer only works for numbers and a few other types. HoneySQL 2.0 fixes that (`sql/format` takes an options hash map in 2.0 and :inline true
will convert "baz"
to 'baz'
when inlining it). But 2.0 isn't close to ready to use yet.
@seancorfield What the status of HoneySQL 2.0?
Very much "in the hammock" 🙂 There's a v2
branch with the current work-in-progress but I need to rework it to lift lift named parameters out if I'm going to support those (I don't use them myself but they are quite popular with others, I believe).
It's not compatible with v1 but it uses different namespaces (so you can use v1 and v2 together). I'm trying to streamline/simplify a lot of the odd quirks and provide easier extension points, as well as covering a lot more of ANSI SQL.