Is there a way in next.jdbc
to treat some column values as keywords? Can I define a coercion around certain columns? I wanted to use keywords as enumerable values.
Which database are you using? https://cljdoc.org/d/com.github.seancorfield/next.jdbc/1.1.646/doc/getting-started/tips-tricks#working-with-enumerated-types
Sounds like you want SettableParameter
- extend that protocol to keywords.
I'm using h2 for tests and will probably use postgres in production
If I read this correctly SettableParameter is only for write? For reads I'll have to implement builders.
There’s a ReadableColumn
protocol as well. It sounded like you wanted to write keywords into enumerations, sorry.
I don’t think you gain much by trying to use keywords for enumerated types, TBH. Converting them to strings on write via SettableParameter
is straightforward, but figuring out which columns need to be keywordized on read is not as simple (because of the API that JDBC affords) and using strings in your code to match these column values isn’t a great hardship — in our experience (with 113K lines of Clojure and a MySQL database full of ENUM
type columns!).
Alright, I'll look into it (after some sleep) Thank you 🙂