Juncture

Introduction

Hi there, recently I have been facing a lot of issues with juncture. Since I want to be an expert in Ruby on Rails let’s see the main functions. In my developper’s life I have seen mainly three differents things for juncture as for now. (Note that this post can be updated and I’ll add the other juncture I’ll face in the future)

def left_joins
def left_outer_joins
def joins

For the three methods, you can find their definitions in on api.rubyonrails.org, here, here and here.

left_join is simply an alias for the function left_outer_joins so we killed one. 2 Lefts.

left_outer_joins is pretty simple, as the doc say :

If you want to select a set of records whether or not they have associated records you can use the left_outer_joins method.

As the function is called, this is an OUTER_JOIN (🤦‍♂️ 😂). This is a short definition :

External juncture to return all the records in the left table. Even if the condition is not verified in the other table.

Basically it means that an OUTER JOIN will always return the values that have or not an associations.

The subtility with the OUTER JOIN is that you’ll probably endup with duplicates especially dealing with has_many association. For example you have a Delivery has_many Articles. Multiple Articles reference the same Delivery so you’ll have duplicates.

left-outer-join

1 Lefts.

The final one joins is an INNER_JOIN juncture. What does that mean ?

This command return the records when there are at least one line in each columns whom matches to the condition.

inner-join

If you understand the concept, there’s no duplicate here, the query will return only the object that have an associations.

Search