korma / Korma

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

Do has-many relations not work with (fields :otherthan*)? #393

Open Janderio opened 6 years ago

Janderio commented 6 years ago

Hi, I have the following test:

Table user [id, username] pk(id) Table emails [user_id, email] pk(user_id, email)

(defentity user 
    (database db)
    (has-many emails))
(defentity emails 
    (database db) 
    (pk [:user_id :email]) 
    (belongs-to user))

When selecting with

(select user 
    (with emails
        (fields :email))
    (fields :*)
    (where {:id 1}))

I am getting the emails as content, when change the (field :*) to (field :username) the :emails is added but empty. The fieldfilter not accepting :emails.email or :email too. Which I tried as I thougth it might be required in this case.

This is the normal behavior or a bug? I supposed it would be possible to filter has-many fields statements too?

Forgot to mention: [korma "0.4.3"]; Oh and mysql with mariadb backend ;)