Skip to content

Fix for generateThroughJoin - #6053

Merged
mickhansen merged 4 commits into
sequelize:masterfrom
harshithkashyap:master
Nov 17, 2016
Merged

mickhansen merged 4 commits into
sequelize:masterfrom
harshithkashyap:master

Conversation

@harshithkashyap

@harshithkashyap harshithkashyap commented Jun 7, 2016 •

Copy link
Copy Markdown

Pull Request check-list

  • Does npm run test or npm run test-DIALECT pass with this change (including linting)?
  • Does your issue contain a link to existing issue (Test Case for #[6052]).
  • Have you added new tests to prevent regressions?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Have you added an entry under Future in the changelog?

Description of change

Added Failing test case & patch for #6052

@harshithkashyap harshithkashyap changed the title Failing testcase for findAll with nested include and inner join on m:n #6052 Failing testcase for findAll with nested include and inner join on m:n issue #6052 Jun 7, 2016
limit: 5,
offset: 0,
order: [
[ { raw: '\`Entity.votes\`' }, 'DESC' ]

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 use proper order syntax for tests, we don't garantee raw

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@mickhansen I have to use raw / sequelize.literal as there is problem with when using

order: [
    [ this.sequelize.col('Entity.votes'), 'DESC' ]
]

I'll raise a separate issue for the same.

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.

@harshithkashyap And what when you use the proper nested order syntax from the docs?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@mickhansen I did. I used

order: [Entity,'votes', 'DESC']
  1. Sequelize generates ORDER BY Entity.votes DESC; which should be ``Entity.votes DESC. Here, `Entity.votes` should be a single string
  2. The order is not applied to the subquery

@mickhansen

Copy link
Copy Markdown
Contributor

Might be simpler to provide this as a sql unit test focusing on where the error happens.

@harshithkashyap

harshithkashyap commented Jun 8, 2016 •

Copy link
Copy Markdown
Author

@mickhansen I've added insert queries & filtered expectations to the test.
I tried looking into writing SQL unit test but it was a little confusing. This is a specific case when subQuery is thrown, there is an inner join with m:n relation using the through object in the join. Not sure how to generate all the cases. Could you guide me a bit? Would be happy to submit the unit test.

@harshithkashyap

Copy link
Copy Markdown
Author

@felixfbecker @sushantdhiman Unit Tests were requested by @mickhansen for this PR. But the generateThroughJoin method here goes through a lot of pre-processing before being called and its very difficult to unit test the same. I've already added integration test for the same.

Incorrent Join identifier is used here and i've submitted a patch for the same. Tests pass in my local instance. Travis CI seems to be stuck because of Deadlock. Could you guys restart the same?

@harshithkashyap

Copy link
Copy Markdown
Author

@felixfbecker @sushantdhiman @janmeier @mickhansen Hey guys, could you review this please?

@felixfbecker

Copy link
Copy Markdown
Contributor

I am not the right person to approve/reject these changes besides code style

@codecov-io

codecov-io commented Nov 7, 2016 •

Copy link
Copy Markdown

Current coverage is 94.50% (diff: 100%)

Merging #6053 into master will not change coverage

Powered by Codecov. Last update 92b36ec...b8c086c

@harshithkashyap harshithkashyap changed the title Failing testcase for findAll with nested include and inner join on m:n issue #6052 Fix for generateThroughJoin Nov 12, 2016
@harshithkashyap

Copy link
Copy Markdown
Author

Ping @janmeier

@mickhansen

Copy link
Copy Markdown
Contributor

We have plenty of other unit tests for SQL generation for joins, it should be possible to cover this case aswell.

@mickhansen
mickhansen merged commit b32ce3c into sequelize:master Nov 17, 2016
@harshithkashyap harshithkashyap mentioned this pull request Nov 17, 2016
4 of 5 tasks
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.

5 participants