Skip to content

fix(query-generator): use where clause of included entity in subquery… - #9165

Closed
jharting wants to merge 1 commit into
sequelize:masterfrom
jharting:fix-9157-1
Closed

jharting wants to merge 1 commit into
sequelize:masterfrom
jharting:fix-9157-1

Conversation

@jharting

@jharting jharting commented Mar 9, 2018

Copy link
Copy Markdown
Contributor

… (#9157)

Closes #9157
Note that this does not fix LIMIT + included entities with WHERE clause completely.
This fix addresses the problem for entities included directly from the top-level entity.
The problem remains for entities that are nested more than level (as the skipped test demonstrates).

I'd like to have this tested and reviewed. If this works I plan to look into the more complex (more levels of nesting) scenarios.

Please make sure to review and check all of these items:

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Did you follow the commit message conventions explained in CONTRIBUTING.md?

Description of change

Looks like most of the code for this was already in place. For some reason it:

  • was triggering for where clauses only, ignoring includes with require=true but no where clause
  • even if triggered it did not copy the where clause over to the subquery

This was pretty simple. If the fix is accepted I plan on looking further into more complex scenarios (more levels of nesting).

…sequelize#9157)

fixes sequelize#9157
Note that this does not fix LIMIT + included entities with WHERE clause completely.
This fix addresses the problem for entities included directly from the top-level entity.
The problem remains for entities that are nested more than level (as the skipped test demonstrates).
@codecov

codecov Bot commented Mar 9, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #9165 into master will not change coverage.
The diff coverage is 100%.

describe(Support.getTestDialectTeaser('Include'), () => {
describe('LIMIT', () => {

let User = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please share these models using test scopes rather than global variables

beforeEach(function() {
  this.Model = sequelize.define(/***/)
})

it('your test', function() {
   this.Model.findAll(/***/)
}); 

@sushantdhiman sushantdhiman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix itself LGTM, can you paste SQL queries for your first test with and without this fix

@jharting

Copy link
Copy Markdown
Contributor Author

@sushantdhiman I am actually going to close this as I am working on a better fix. I'll submit a new one with SQL examples shortly

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

limit/offset produces invalid result if included model has where clause

2 participants