Fork me on GitHub
#sql
<
2024-06-29
>
Ovi Stoica04:06:09

I inherited a postgres DB that was made with an ORM and I want to run some scripts. My issue is that it has camelCased columns and queries need to be ran like "INSERT INTO tests (name, \"subchapterId\") VALUES (?, ?)" from next.jdbc perspective Is there a helper or method to handle these correctly with next.jdbc or honeysql? Sth like (-> (insert-into :subchapter) (columns :name "subchapterId")) ? Currently I can manage with raw sql queries but It’s not ideal

seancorfield06:06:42

You mean like this?

user=> (-> {:insert-into :tests :columns [:name :subChapterId] :values [["one" 2]]} (sql/format {:quoted true}))
["INSERT INTO \"tests\" (\"name\", \"subChapterId\") VALUES (?, ?)" "one" 2]

seancorfield06:06:50

That's kinda the point of :quoted true...

Ovi Stoica05:06:23

Ah perfect! Thank you, Sean! Sorry I didn’t find that in the docs. I think I should’ve looked more

seancorfield05:06:37

NP. next.jdbc docs are pretty dense. If you have suggestions on how to make that easier to find, LMK.