sql

Ovi Stoica 2024-06-29T04:55:09.799509Z

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

Ovi Stoica 2024-06-30T05:37:23.031369Z

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

seancorfield 2024-06-30T05:41:37.919889Z

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

seancorfield 2024-06-29T06:50:42.581049Z

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]

seancorfield 2024-06-29T06:51:50.913459Z

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