korma / Korma

Tasty SQL for Clojure.
http://sqlkorma.com
1.48k stars 222 forks source link

Add support for joining entities, using a specific join-type #247

Closed DTB01 closed 9 years ago

DTB01 commented 9 years ago

Currently, it is possible to specify a type (e.g. :inner) when doing a join with an explicit clause

(select "users" (join :inner "email" (= :email.users_id :id)))

When joining entities based on their relation as below, the type is defaulted to :left

(select users (join email))

And it is not possible specify a type, i.e. not possible to do

(select users (join :inner email))

I've enabled this and made the change so that the arglists look like so

[query ent]
[query type ent] ;new
[query table clause]
[query type table clause]

I believe this is very helpful as it allows us to join entities using an arbitrary join-type, without having to repeat the join constraints from the rels that we already defined in defentity.

immoh commented 9 years ago

Some things to fix before I can merge this:

Thanks.

DTB01 commented 9 years ago

Will fix tests and docstring. The extra type arg to add-joins seem necessary. Unless i am completely missing something here.....

Thanks

DTB01 commented 9 years ago

Fixed docstring and added tests. Squashed and rebased.

Cheers

immoh commented 9 years ago

Thanks!