New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Association filtering and inner join #1199

Merged
merged 5 commits into from Jan 4, 2014

Conversation

3 participants
@mickhansen
Contributor

mickhansen commented Jan 4, 2014

Makes it possible to force a INNER JOIN by setting required: true as a option to include:

Project.findAll({
  include: [
    {model: User, required: true}}
  ]
})
// SELECT * FROM project INNER JOIN user ON project.user_id = user.id 

If there is a where condition on the include it will be required: true by default.

Project.findAll({
  include: [
    {model: User, where: {last_name: 'Hansen'}}
  ]
})
// SELECT * FROM project INNER JOIN user ON project.user_id = user.id AND user.last_name = 'Hansen'

mickhansen added a commit that referenced this pull request Jan 4, 2014

Merge pull request #1199 from mickhansen/association-filtering
Association filtering and inner join

@mickhansen mickhansen merged commit ad7ec9a into sequelize:master Jan 4, 2014

1 check passed

default The Travis CI build passed
Details

@mickhansen mickhansen deleted the mickhansen:association-filtering branch Jan 4, 2014

@JohannesBeranek

This comment has been minimized.

JohannesBeranek commented Jan 14, 2015

just commenting in case someone else finds this: reading the source it's
required ? 'INNER JOIN' : 'LEFT OUTER JOIN'

@mickhansen

This comment has been minimized.

Contributor

mickhansen commented Jan 14, 2015

@griffin1987 good catch, i made a typo which i've corrected now.

@davidrapin

This comment has been minimized.

Contributor

davidrapin commented Jun 16, 2015

@JohannesBeranek thank you !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment