Does include() work with Model.where()?

45 views
Skip to first unread message

evan.leonard

unread,
May 1, 2012, 1:31:49 PM5/1/12
to activejd...@googlegroups.com
I'm using Model.where() with an IN clause to load lists of models associated with another list of models. I'm tried using .include on one of my where queries to do part of the work for me, but it didn't seem to work over a polymorphic association (parent_id & parent_type columns in the table). Is this a known issue or should I try to create a test case?

Evan

ipolevoy

unread,
May 1, 2012, 3:33:07 PM5/1/12
to activejd...@googlegroups.com
Looking at code in LazyList, I see no support for include() for polymorphic associations.
It should be possible to add it though, if you feel strongly about it

thanks
igor

ipolevoy

unread,
May 1, 2012, 4:42:24 PM5/1/12
to activejd...@googlegroups.com
Evan, I filed a new issue:
http://code.google.com/p/activejdbc/issues/list?cursor=activejdbc%3A158&ts=1335904895&updated=158
this will be completed soon, I will announce here

thanks
igor

ipolevoy

unread,
May 1, 2012, 4:42:49 PM5/1/12
to activejd...@googlegroups.com

evan.leonard

unread,
May 1, 2012, 5:24:21 PM5/1/12
to activejd...@googlegroups.com

I'll do you one better. Attached is a patch with the fix. All tests pass :)

This includes my other patch with the new signature for collect, as this fix requires that one.

Evan
include_for_polymorphic_parents.txt

evan.leonard

unread,
May 1, 2012, 5:33:09 PM5/1/12
to activejd...@googlegroups.com
all tests pass on mysql that is...

ipolevoy

unread,
May 1, 2012, 5:57:25 PM5/1/12
to activejd...@googlegroups.com
Man, what a coincidence, I'm working on polymorphic children, almost done!
I will include your patch too, thank you

Evan Leonard

unread,
May 1, 2012, 6:10:39 PM5/1/12
to activejd...@googlegroups.com

Whew. I saw your post and thought "oh no! we probably did the same thing!" Glad we didn't collide :)

Evan

ipolevoy

unread,
May 1, 2012, 6:14:48 PM5/1/12
to activejd...@googlegroups.com
missed each other by a mere inch:)
Reply all
Reply to author
Forward
0 new messages