Skip to content
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

Why the 'subQuery' option from findAll() isn't on the documentation? #7865

Closed
edu791 opened this issue Jun 29, 2017 · 9 comments
Closed

Why the 'subQuery' option from findAll() isn't on the documentation? #7865

edu791 opened this issue Jun 29, 2017 · 9 comments
Labels
type: docs For issues and PRs. Things related to documentation, such as changes in the manuals / API reference.

Comments

@edu791
Copy link

edu791 commented Jun 29, 2017

No description provided.

@felixfbecker
Copy link
Contributor

Cause it is one of these "only use them if you know what you're doing" options. You can only use them for 1:n relations if you know for sure that your include will only yield one result (because of JOIN or WHERE conditions etc.). That said, if the caveats are documented, I don't see a reason why it shouldn't be documented.

@felixfbecker felixfbecker added the type: docs For issues and PRs. Things related to documentation, such as changes in the manuals / API reference. label Jun 30, 2017
@felixfbecker
Copy link
Contributor

As I said, if the caveats are documented, I don't see a reason why it shouldn't be documented. Feel free to do a PR

@stale stale bot added the stale label Aug 29, 2017
@stale
Copy link

stale bot commented Aug 29, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂

@stale stale bot closed this as completed Sep 5, 2017
@sushantdhiman sushantdhiman reopened this Sep 22, 2017
@apapap
Copy link

apapap commented Oct 15, 2017

Like eduardrock, I only discovered the 'subQuery' option because of a comment buried in a StackOverFlow question. It first took me a while to recognize that Sequelize was using a subquery in the FROM clause. Then, I spent hours wondering why. Scouring the documentation, I couldn't figure it out.

"You can only use them for 1:n relations if you know for sure that your include will only yield one result (because of JOIN or WHERE conditions etc.)."

An explanation of why and when subqueries are used would be helpful. In my case, I wanted parent.findAll() to include a COUNT and MIN of fields from a child table, in addition to all the parents' other fields. Seems like a situation many people would run across. Looks like a limit I included was causing Sequelize to generate the subquery. I almost gave up and used a separate raw query.

Thanks all for your work on Sequelize. It's had a big impact on many projects, including mine.

@stale
Copy link

stale bot commented Jul 23, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂

@stale stale bot added the stale label Jul 23, 2019
@papb papb removed the stale label Jul 24, 2019
@jmwielandt
Copy link

jmwielandt commented May 30, 2021

Greetings from the future! (?)

I've discovered the option because of the linter. Now reading first @felixfbecker comment I think the bug I've found yesterday (not reported yet) with a top-level condition using $nested.columns$ ("$axis.subject.students.id$": userId, where User and Subject has a many-to-many relationship called "StudentsSubject") could be due to this option was enabled by default.
🤔
I'm bussy right now, eventually I'll come back with news. Comments on this are appreciated btw~

@jmwielandt
Copy link

@edu791 hi, ironically we are switching our project from typeorm to sequelize (using sequelize-typescript and type-graphql) due to the insane lack of documentation of typeorm and we are already happy with our decision 😂

@ephys
Copy link
Member

ephys commented Feb 5, 2022

It's not in the guides part of the documentation but it is present & explained in our jsdoc. Should become visible on the website once we're done with #13914

@ephys
Copy link
Member

ephys commented Apr 16, 2022

It is part of the API reference now

@ephys ephys closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: docs For issues and PRs. Things related to documentation, such as changes in the manuals / API reference.
Projects
None yet
Development

No branches or pull requests

7 participants