Hey Jeremy, I'm trying to set up a relationship in a model that generates 
SQL like the following join with an OR between the conditions.

SELECT * FROM table1 INNER JOIN table2 ON (("table2"."resource_id" = 
"table1"."an_id") OR ("table2"."resource_id" = "table1"."another_id")) 
WHERE (("table2"."user_id" = <id>)

This is the closest I've come:

User.many_to_many(:table1, join_table: :table2, right_key: [:resource_id, 
:resource_id], right_primary_key: [:an_id, :another_id])

However, this generates an AND

SELECT * FROM table1 INNER JOIN table2 ON (("table2"."resource_id" = 
"table1"."an_id") AND ("table2"."resource_id" = "table1"."another_id")) 
WHERE (("table2"."user_id" = <id>)

Any ideas on how I can generate the query with the OR?

-- 
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 sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/a431b1f6-8f57-4ee3-8465-22f0eccf4cc8n%40googlegroups.com.

Reply via email to