Fork me on GitHub
#sql
<
2021-03-11
>
piotrts13:03:51

Hello. Does anybody know how to add a "for update nowait" clause in Korma? The closest thing I found is korma.core/modifier, but it adds the clause to the beginning of the query:)

borkdude14:03:21

I'm surprised korma is still being used. Last time I heard about it was maybe 7-8 years ago!

piotrts15:03:32

Yep, it's not great, but IMHO if it is used as a simple DSL (and if all the inputs are sanitized 🙂) does the job well

seancorfield17:03:13

HoneySQL V2 supports that (and is a much more complete DSL than Korma).

piotrts22:03:23

Thanks, but unfortunately migrating to HoneySQL is not an option... I ended up writing a parametrised sql query and executing it via korma...

raspasov20:03:03

Does anybody know of a Clojure SQL library that automatically transforms SQL results into tree-like structures (ideally via foreign keys, etc)? I feel like a saw a library like that, but I can’t remember the name.

seancorfield20:03:21

I've had a few requests over the years for adding such functionality to the various SQL-related libs I maintain so if you find anything, I'd be very interested.

raspasov20:03:44

Perhaps this (but I think it was a different library that I saw): https://github.com/metabase/toucan

seancorfield20:03:12

The closest in c.j.j / next.jdbc is the datafy/`nav` support that lets you lazily traverse the DB via FK relationships (but they are defined by convention or in data -- not derived from the DB metadata).

seancorfield20:03:11

Toucan feels very OOP/ORM-y to me...

raspasov20:03:21

Yeah… you need to define your model… And this whole “hydration” talk 🙂 But I haven’t gone through it carefully, just now seeing it for the first time.

raspasov20:03:49

Perhaps datafy/nav is good enough… I gotta give it a shot. Thanks @seancorfield 🙂

raspasov20:03:23

So it let’s you retrieve a map-in-map-etc based on foreign-keys, as I understand

raspasov20:03:21

You can have something like:

{:order-id 1
 :name     "X"
 :address  {:street "123 Main"
            :zip    "99999"
            :city   "XYZ"}}
… from two tables, let’s say “orders” and “addresses” where :address is a foreign key in the “orders” table, pointing to “addresses” table?

seancorfield20:03:50

I don't understand what you're asking, sorry.

raspasov20:03:22

My bad, it’s not a clear example. I’ll explore further.

vemv21:03:04

I used to enjoy https://github.com/paper-trail-gem/paper_trail in my Rails years. Versioning/auditing is a big reason why Datomic, ES/CQRS, etc have traction. paper_trail gives one something equivalent while still having the benefits of SQL (I particularly like its leanness). Anyone has attempted to code an paper_trail equivalent in clj ?