honeysql

Discussion of https://github.com/seancorfield/honeysql :slightly_smiling_face:
Cory 2020-08-02T01:40:04.321400Z

is there a way to differentiate between reference and value structures when using keywords? using a keyword from clojure.java/jdbc things get interpolated correctly using a protocol extension on ISQLParameter, but from honeysql the keyword renders as a database reference. i've solved this by single-quoting the tail of the keyword, but wonder if i'm missing something since i started futzing with honeysql main to support this as i expected.

seancorfield 2020-08-02T01:55:54.322Z

@goedelsoup Can you share some code? Not quite sure what you're referring to...

seancorfield 2020-08-02T01:57:45.322500Z

I'm having a hard time imagining the HoneySQL code you're talking about...

Cory 2020-08-02T02:04:17.323600Z

cleaned it as well as i could....`triage-status` here is a keyword representing an enum

(-> (sqlh/select :*
    (sqlh/from [member-subquery :member_subquery])
    (sqlh/where [:= :covid_registry_rank 1])
    (sqlh/merge-where [:= :triage-status triage-status])
so it gets rendered as a column reference vs a value, which was the dev's intent.

Cory 2020-08-02T02:05:14.324100Z

i dug into format and to-sql and this distinction seems hard to make

Cory 2020-08-02T02:06:23.324400Z

as is, the value ends up as the column name on the RHS

Cory 2020-08-02T02:09:13.325400Z

i agree with how this is constructed, so my question is moreso, how should you construct a predicate based on a keyword which is an enumeration

seancorfield 2020-08-02T02:09:49.326100Z

Ah, okay, yes... That's a tricky one since, "by definition" in HoneySQL, keywords are always treated as references to SQL entities.

seancorfield 2020-08-02T02:10:18.326600Z

If you prefix it with #sql/inline, does that work?

seancorfield 2020-08-02T02:10:33.327100Z

(assuming you have the readers in play)

Cory 2020-08-02T02:10:51.327300Z

nope, i have to single quote the tail of the keyword afaik

Cory 2020-08-02T02:11:23.327700Z

i will double check that, but i tried a lot of things before i realized what was going on

seancorfield 2020-08-02T02:15:35.328500Z

Feel free to open an issue on the repo with repro details. This is exactly the sort of thing I want to try and fix in HoneySQL 2.0.

👍 1
Cory 2020-08-02T02:17:51.329500Z

i don't have gripes with it and i have workarounds. it's a positional variable, so i understand the difficulty, i'll try to minimize an example in an issue.