Hi Jeremy,
I had a quick question about using associations - I'm trying to add an
association that joins on two keys, but where one of those two keys should
also allow NULL values. So essentially the dataset I want it to return
should be:
SELECT * FROM base_table INNER JOIN foos ON (base_table.key_1 = foos.key_1
AND (base_table.key_2 = foos.key_2 OR foos.key_2 IS NULL))
Or in other words, the query to return the dataset of foos associated with
a given record in the base table (e.g. the record where key_1 is 1 and
key_2 is 1) would be:
SELECT * FROM foos WHERE (foos.key_1 = 1 AND (foos.key_2 = 1 OR foos.key_2
IS NULL))
I currently have the association specified as follows:
one_to_many :foos,
:key => [:key_1, :key_2],
:primary_key => [:key_1, :key_2]
but as you can imagine, this returns no association results in the case
where key_2 is NULL. What's the right way to specify this?
Thanks,
Craig
--
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/d/optout.