Hi Jeremey!

You're right,
allthough one behaviour which I think is a bit incorrect is that it seems
to do the slicing after fetching nested associations. for example
Article.eager(:recent_**comments => :user).limit(10).all

the recent_comments association is limited to 5, but the query for fetching
the user for each comment has all comments returned from the first query in
it, not just the limited subset.

Thanks
Edward



On 1 October 2013 16:01, Jeremy Evans <[email protected]> wrote:

> On Tuesday, October 1, 2013 2:16:00 AM UTC-7, Edward J wrote:
>
>> Hi,
>>
>> Is it possible to accomplish a similar result as when you use a limited
>> association in postgres with mysql
>>
>> for example:
>>
>> I have a association set up as
>> one_to_many :recent_comments, :class => :Comment, :order => :date, :limit
>> => 5
>>
>> if I run Article[123].recent_comments it works as expected but if i want
>> to fetch multiple articles and eagely fetch this association it ignores the
>> limit.
>>
>> Article.eager(:recent_**comments).limit(10).all
>> just runs
>>
>> SELECT * FROM `comments` WHERE (`comments`.`article_id` IN (1, 2, 3
>> ....)) ORDER BY `date`
>>
>> I know mysql doesn't support the partition by syntax, but is there
>> another way around this to limit eager fetching of associations?
>>
>
> Sequel used to support a correlated_subquery eager limit strategy, but it
> was removed in 4.0 as it wasn't very portable, and in some cases could
> cause even worse performance.  Note that Sequel still returns the correct
> results in this case, since it does array slicing in ruby.
>
> Thanks,
> Jeremy
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sequel-talk" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sequel-talk/gCS3uaatfgU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sequel-talk.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to