sql

All things SQL and JDBC...
piotrts 2021-03-11T13:06:51.027400Z

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:)

borkdude 2021-03-11T14:32:21.027700Z

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

piotrts 2021-03-11T15:11:32.030400Z

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

seancorfield 2021-03-11T17:26:13.030900Z

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

raspasov 2021-03-11T20:23:03.032200Z

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.

seancorfield 2021-03-11T20:26:21.033100Z

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.

raspasov 2021-03-11T20:26:44.033800Z

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

seancorfield 2021-03-11T20:27:12.034700Z

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).

seancorfield 2021-03-11T20:28:11.035400Z

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

raspasov 2021-03-11T20:29:21.036800Z

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.

raspasov 2021-03-11T20:34:49.037900Z

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

raspasov 2021-03-11T20:35:23.038700Z

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

raspasov 2021-03-11T20:38:21.040400Z

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?

seancorfield 2021-03-11T20:50:50.040700Z

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

raspasov 2021-03-11T20:58:22.042400Z

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

vemv 2021-03-11T21:16:04.047300Z

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: ?

piotrts 2021-03-11T22:31:23.047500Z

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