Fork me on GitHub

Hi all! I was wondering if using a result (perhaps just a fixed value?) from a (jdbc/with-transaction ...) block (which does some inserts) is a sufficient check whether the transaction was executed successfully? Like anything other than an exception is a success… Or is there a better way to conditionally run business logic after a transaction?


If I have a keyword value on clojure, what would be the way to store that in sql? how about reading it back to a keyword (namespaced) in next.jdbc?


or is it a better practice to already have those values as strings in clojure?

Cora (she/her)21:04:53

you'd need to convert it to edn


not sure I follow, what would be the type I would use in e.g. Postgresql? I was thinking string so that I can do indexing etc, you mean converting it manually on writing/reading?


I was wondering if there was a way to automatically convert a given column , but I guess doing the conversion when reading/writing does also work

Cora (she/her)21:04:20

that will convert to/from json for you. I'm sure there's a way to like make a custom type in postgres and add automatic conversion with edn but really that seems like a huge pain


I was thinking on primite type colums (a string in DB that is a keyword on clojure, or enum in pg maybe?), but I’ll also need that for json/edn interop, thanks


hmm enums like described here might be what I was looking for:

Cora (she/her)21:04:13

that jdbc/IResultSetReadColumn looks like it could potentially cause some issues

Cora (she/her)21:04:52

if any other string column gets one of the enum values it would automatically convert that, too

Cora (she/her)21:04:35

also that looks like it's using the old version of jdbc for clojure

Cora (she/her)21:04:09

specifically instead of the newer next.jdbc

Cora (she/her)21:04:05

I'd just accept that it's going to be a string, myself


yes you’re right, I think I’d change the implementation, though going for enums might be a reasonable approach (as the kw values I was thinking of are specced as sets of possible values in clojure)


the easier way seems to be to transform directly on clojure and have it as string


I’ll investigate a bit more but it looks like the solution will come from one of those two approaches


thanks for the help!

Cora (she/her)21:04:50