Method: InterMine::PathQuery::Query#add_join
- Defined in:
- lib/intermine/query.rb
#add_join(path, style = "OUTER") ⇒ Object Also known as: join
Declare how a particular join should be treated.
The default join style is for an INNER join, but joins can optionally be declared to be LEFT OUTER joins. The difference is that with an inner join, each join in the query implicitly constrains the values of that path to be non-null, whereas an outer-join allows null values in the joined path. If the path passed to the constructor has a chain of joins, the last section is the one the join is applied to.
query = service.query("Gene")
# Allow genes without proteins
query.add_join("proteins")
# Demand the results contain only those genes that have interactions that have interactingGenes,
# but allow those interactingGenes to not have any proteins.
query.add_join("interactions.interactingGenes.proteins")
The valid join styles are OUTER and INNER (case-insensitive). There is never any need to declare a join to be INNER, as it is inner by default. Consider using Query#outerjoin which is more explicitly declarative.
697 698 699 700 701 702 703 704 |
# File 'lib/intermine/query.rb', line 697 def add_join(path, style="OUTER") p = InterMine::Metadata::Path.new(add_prefix(path), @model, subclasses) if @root.nil? @root = p.rootClass end @joins << Join.new(p, style) return self end |