Fork me on GitHub
#honeysql
<
2024-02-14
>
ilmo15:02:15

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

1
ilmo16:02:07

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

ilmo16:02:43

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

p-himik16:02:33

Shouldn't be any risk.

p-himik16:02:12

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

ilmo16:02:25

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.

ilmo16:02:39

Maybe that’s a hard one to answer.

ilmo16:02:55

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

ilmo16:02:55

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