honeysql

ilmo 2024-02-14T15:56:15.124609Z

Any risk in using :lift for non-JSONB data types categorically?

✅ 1
ilmo 2024-02-14T16:00:07.033939Z

Eg:

(-> (sql.h/insert-into :my-foo [:id
                                :jsonb-1
                                :jsonb-2
                                :frob])
    (sql.h/values [[1
                    [:lift {}]
                    [:lift []]
                    [:lift "text"]]])
    sql/format)
=> ["INSERT INTO my_foo (id, jsonb_1, jsonb_2, frob) VALUES (?, ?, ?, ?)" 1 {} [] "text"]

ilmo 2024-02-14T16:02:43.638379Z

Already aware of this: https://clojurians.slack.com/archives/C66EM8D5H/p1643310886155809 I guess it would affect the prepared statement slightly 🤔

p-himik 2024-02-14T16:03:33.314709Z

Shouldn't be any risk.

p-himik 2024-02-14T16:04:12.403319Z

Well, unless you start wrapping wrong things, i.e. data structures that HoneySQL is supposed to parse. :)

ilmo 2024-02-14T16:11:25.356939Z

Thanks! Would you say this is rarely the case when passing values inside values ? In my case the values [1 {} [] "text"] (or whatever values are passed in) would get wrapped with :lift , no questions asked.

ilmo 2024-02-14T16:12:39.261419Z

Maybe that’s a hard one to answer.

ilmo 2024-02-14T16:15:55.227869Z

Okay, all I had to do was to ask the REPL:

(sql/format (sql.h/values [{:id 1 :value [:inline "moi"]}]))
=> ["(id, value) VALUES (?, 'moi')" 1]
(sql/format (sql.h/values [{:id 1 :value [:lift [:inline "moi"]]}]))
=> ["(id, value) VALUES (?, ?)" 1 [:inline "moi"]]

ilmo 2024-02-14T16:18:55.286319Z

Doesn’t really answer the question about occurrence rate, but clears up my understanding of what is meant by HoneySQL parseables. Occurrence rate was perhaps the wrong question and something for me to figure out in my context. Thanks for the help!

👍 1