korma / Korma

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

entity transforming doesn't work on subselect and relation-included selects #215

Closed clyce closed 10 years ago

clyce commented 10 years ago

R.T

As an entity defined below:

(defentity some-ent 
  ...
  (transform some-fn)
  ...
  )

on the code below, some-fn is applied

(select some-ent)

but, when trying the code below, the some-ent doesn't transform through some-fn:

(union 
  (queries (subselect some-ent (where some-map-0))
                (subselect some-ent (where some-map-1))))

and when I define an entity has some relation with some-ent(e.g has-one)

(defentity another-ent
  ...
  (has-one some-ent)
  ...
  )

as I query

(select another-ent (with some-ent))

the result of some-ent is not transformed.

I don't know why, but things goes like that.

looking forward to your reply, thanks~

immoh commented 10 years ago

There is already issue for transform fns not running for one-to-one relations: #188

The result of union could be data from several different entities/tables and therefore transform fns cannot be really applied on the result set. In order to do that, Korma would need to execute each subquery separately, run transform fns and combine the results.

immoh commented 10 years ago

This is was already fixed 0.3.0