honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
Yehonathan Sharvit 2020-12-15T11:44:16.228600Z

Hello there, I love honeysql

Yehonathan Sharvit 2020-12-15T11:44:59.229400Z

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"]

Yehonathan Sharvit 2020-12-15T11:45:38.230200Z

I’d like to generate the following string

SELECT a, b, c FROM foo WHERE f.a = "baz"

Yehonathan Sharvit 2020-12-15T11:46:02.230800Z

The reason is that I’d like to be able to copy and paste the query into a SQL console

Yehonathan Sharvit 2020-12-15T14:37:07.231100Z

I found it!

user=> (sql/format sqlmap :parameterizer :none)
["SELECT a, b, c FROM foo WHERE f.a = baz"]

dharrigan 2020-12-15T14:37:35.231400Z

:party-corgi:

2020-12-15T14:45:42.232Z

That doesn’t look quite right. Shouldn’t baz be in single quotes?

seancorfield 2020-12-15T18:22:59.234Z

@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.

Yehonathan Sharvit 2020-12-15T20:12:20.234600Z

@seancorfield What the status of HoneySQL 2.0?

seancorfield 2020-12-15T20:48:24.236100Z

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

seancorfield 2020-12-15T20:49:43.237400Z

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.