ibdknox/Korma — Issue #42: Missing join from has-one/has-many directive
Author: jsyrjala
Created: 2012-02-05 09:59:50+00:00
State: open

Following statement returns a wrong query:

```clojure
(sql-only (select event (with tracker event-location)))
"SELECT \"events\".* FROM \"events\" LEFT JOIN \"trackers\" ON \"trackers\".\"id\" = \"events\".\"tracker_id\""
```

There should be an additional ```LEFT JOIN events.id = event_locations.event_id```. This happens in 0.3.0-beta2, earlier version 0.2.0 and 0.2.0-SNAPSHOT didn't have this problem. The same thing happens if I change has-one to has-many.

I have following entity mappings.

```clojure
(defentity tracker
(table :trackers)
(pk :id)
(entity-fields :id :tracker_identifier :name)
)

(defentity event-location
(table :event_locations)
(pk :id)
(entity-fields :latitude :longitude)
)

(defentity event
(pk :id)
(table :events)
(entity-fields :id :event_time :created_on)
(belongs-to tracker {:fk :tracker_id})
(has-one event-location {:fk :event_id})
)
```