Did not know about the qualify method, that's awesome. Thanks! - Aryk

On Sunday, June 11, 2017 at 8:06:48 AM UTC-7, Jeremy Evans wrote:
>
> On Saturday, June 10, 2017 at 4:41:56 PM UTC-7, Aryk Grosz wrote:
>>
>> Hi Jeremy,
>>
>> Just curious, how do you expect one to handle a join happening after a 
>> call to "this" such that there are multiple primary keys?
>>
>> The code in #this looks like:
>>
>> cond = if ds.joined_dataset?
>>   qualified_pk_hash
>> else
>>   pk_hash
>> end
>>
>>
>> So if you do this.association_join(:association).select_map([:id]), the 
>> where condition would throw an error since :id is ambiguous.
>>
>
> You should do something like:
>
>   
> this.qualify.association_join(:association).select_map([Sequel[:table][:id]])
>
> Calling qualify will automatically qualify the WHERE condition.  You need 
> to manually use a qualified argument to select_map, using the appropriate 
> table (the current one or associated one, depending on what you want).
>
> An alternative to qualify would be to use a subselect:
>
>   
> this.from_self(:alias=>this.first_source).association_join(:association).select_map([Sequel[:table][:id]])
>
> 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