Got it! Thanks for the explanation. Is this constraint written somewhere in 
the documentation? It seems kind of non-obvious.

On Monday, June 5, 2017 at 10:12:14 AM UTC-7, Jeremy Evans wrote:
>
> On Monday, June 5, 2017 at 1:52:45 AM UTC-7, Aryk Grosz wrote:
>>
>> I have a very similar example to this:
>>
>> https://groups.google.com/d/msg/sequel-talk/muJ14cXsnpA/YK1eV65-5qYJ
>>
>> You propose to solve it with this:
>>
>> Artist.many_to_many :songs, :join_table=>:albums, :right_key=>:id, 
>> :right_primary_key=>:album_id
>>
>>
>> This works for the normal usages like
>>
>> artist.songs
>>
>> However, if you do
>>
>> artist.song_pks, it will not return the correct values. I believe it 
>> tries to get the values off the intermediary table (like as if it were a 
>> real join table, which it isn't) and that's what is causing the issues 
>> since it actually needs to join over to the songs table via the album_id 
>> field and then look up the primary keys on that table.
>>
>> Or maybe I'm missing something?
>>
>
> You aren't missing something, it doesn't work for that use case as it 
> assumes that right_key in the join table contains the necessary values.  In 
> order to support this case, we'd need to support an additional association 
> option that specified the associated model table needs to be joined to and 
> the primary key for the association model table used.
>
>  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