I just don’t consider it a problem. A query returns a flat result set — a 
sequence of hash-maps. That’s it. That’s what SQL returns (essentially a table) 
and it’s a perfectly reasonable data structure for Clojure to work with.

The JOINs in SQL just say how to link tables together to produce that (flat) 
result set. Any structural grouping semantics you want to apply are up to your 
application.

FWIW, I find ORMs — which is where you’re going with this — to be far more 
trouble than they’re worth and I just don’t see the benefit in Clojure which is 
all about pure data structures. I worked with a lot of ORMs — and written 
several of my own — over the last couple of decades and these days I just avoid 
them.

Sean

On May 24, 2015, at 3:10 AM, Krzysiek Herod <krzysiek.he...@gmail.com> wrote:
> It seems to me that it's a problem that sooner or later appears in any 
> project using relational database (apart form easy cases, when there is no 
> many relations between tables). Am I missing something? How do you guys work 
> with database results of queries containing several tables referring to each 
> other? 
> 
> W dniu czwartek, 21 maja 2015 21:57:03 UTC+2 użytkownik Krzysiek Herod 
> napisał:
> I've found the question appearing here, but a long time ago, so I thought 
> that maybe the situation changed:
> 
> Is there a relational mapper in clojure (or in java) that takes query result 
> and generates an array of hashmaps?
> I mean something that converts the result of this query:
> "SELECT * FROM posts LEFT JOIN comments ON (comments.post_id = posts.id 
> <http://posts.id/>) LEFT JOIN users ON (posts.user_id = users.id 
> <http://users.id/>)"
> into (for example) the following structure:
> [{:title "Post title" :user {:first_name "User 1"} :comments [{:title 
> "Comment 1"} {:title "Comment 2"}]}]
> 
> I've used kormadb for that, but it works like this only with has-many 
> relation (belongs-to puts all of the fields from related tables into the same 
> hash as if it was one table, and using "with" do not solve the problem 
> neither).
> 
> Is there any other clojure library that does that, or is any java library 
> used instead?  


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to