Open solnic opened 6 years ago
I'm not sure if we want to support :view
option along with wraps, because they use joins instead of composition so it's really hard to tell how such a custom view is supposed to be used. Good news is that in rom 4.0 wrap
will be part of the core API (already in master) so that you'll be able to easily define your own relation view that uses wrap
and do whatever you want there.
I'll leave this open for further discussion.
@flash-gordon do you have any idea how this could be done?
From @flash-gordon on June 27, 2017 11:11
🤔
@solnic what if we join base relations by default? I.e. users
has many visible_comments
, where visible_comments
is a view defined to comments
, then we just do join on users.id = comments.user_id
, no matter how visible_comments
is defined (user_id
might not present in visible_comments
we should raise an error in this case, I think it's fine for now). And in other cases we could leverage the block syntax you proposed in the chat
@flash-gordon I'm not sure if I follow :)
From @flash-gordon on June 28, 2017 11:18
@solnic lol, let's put it in another form, what's the problem with joining a view? RDMS has a similar concept of a "database view" and it's absolutely legal to join a view. We can do something very similar by, say, joining a subquery. WDYT?
ah yeah, this makes sense
From @johnnoone on June 9, 2017 10:49
I've defined 2 relations, one with a custom view (to filter some columns), and an association to that view.
When I use
relation.combine_children
, it works as expected and linked entity returns only the wanted fields. But when I userelation.wrap
, it does not respect the custom view.For example this script:
Wrap query returns
Expected
Copied from original issue: rom-rb/rom#407