Hi Jeremy,

I'll try that out. I'm afraid this is stretching the limits of my SQL 
knowledge, so I'm not sure exactly the SQL I want, but I think I understand 
what your query is doing so I'll play with it and let you know if I come to 
a better understanding and need to learn something different :)

Thanks so much for all your help. I don't know how you keep up with all us 
folks, but it's really appreciated!

Andrew

On Thursday, November 10, 2016 at 5:38:59 PM UTC-5, Jeremy Evans wrote:
>
> On Thursday, November 10, 2016 at 1:40:06 PM UTC-8, Andrew Burleson wrote:
>>
>> Hey Jeremy, thanks so much for this answer. After some fiddling around I 
>> got it to do what I wanted, but now I ran into another interesting side 
>> effect.
>>
>> When it comes to limiting the results, I'd ideally like to limit by a 
>> total number of conversations and load however many messages that happened 
>> to include. IE: load three conversations, and if each conversation has 5 
>> messages or 50 messages, I don't really care.
>>
>> When I use .limit on the end of that eager graph, it's limiting the total 
>> number of messages coming through, which I think I understand from a 
>> dataset point of view.
>>
>> However, since that's not really the behavior I want, is there any way to 
>> limit on the number of conversations returned instead of the number of 
>> messages?
>>
>
> It would be better to describe the SQL you want to execute.  Since you 
> didn't do that, my guess is you want something like:
>
>   ds = Conversation.eager_graph(:messages=>:user).where{{users[:id]=>1}}
>   
> ds.where{{conversations[:id]=>ds.select(conversations[:id]).from_self.distinct.order(:id).limit(3)}}.all
>
> That makes the limit pick the first three matching conversations by id. If 
> you want to limit based on an existing order on the dataset, that's going 
> to be more involved.  In that case, you really need to describe what SQL 
> you want to execute.
>
> Thanks,
> Jeremy
>

-- 
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 https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to