-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Query breaks after adding skip and take #2912
Comments
Happening to me too. Any workaround? |
I'm also having this problem. Posting some info about my code, hopefully that helps narrow it down. This is basically the query I'm trying to run:
This returns this query with .getSql(), which looks how I would expect it to (with no LIMIT/OFFSET clauses, which I understand is due to how take/skip work):
However, if I try to get any results, using
This should return the appropriate "id"s from the customer table so that another query can run to select just those rows from the original query. However, we get a an error: This query would work if the GROUP BY clause I indicated in my original query was included in the subquery generated by TypeORM. I believe the ORDER BY clause should also go inside the subquery. Is there any way to force this to happen, or should I just be using limit and offset in this kind of case? |
@akosasante have you solved your problem? If yes then can you please describe how. Because I getting same response from query when try to use |
@deeptechuz Nope, I just ended up using |
@akosasante Thanks bro, I guess currently no solution available for this issue. I will do same 😞 |
Having similar problem here - except my error is Hacked for now by replacing take and skip by limit and offset Edit: My problem happened when |
Actually this isn't a bug. When you use
|
it works for me when I add the join condition to
|
it works for me when I replace |
Agreed - needs For other questions, please check out the community slack or check TypeORM's documentation page on other support avenues - cheers! |
I'm facing the same issue as described here, using This is my method async find(search: string, options: Paginate) {
const qb = this.postRepository
.createQueryBuilder('p')
.innerJoin('p.owner', 'u', 'u.id = p.ownerId')
.innerJoin('mentor', 'm', 'u.id = m.userId')
.select(['p.*',
'u.username as "ownerUsername"',
'u.name as "ownerName"',
'u.avatar as "ownerAvatar"',
'm.service as "ownerService"'
])
.take(options.limit)
.skip(options.offset)
if (search) {
qb.where('p.title ilike :sq', {sq: `%${search}%`})
qb.orWhere('p.text ilike :sq', {sq: `%${search}%`})
}
console.info(qb.getQueryAndParameters());
return qb.stream();
} Versions:
|
Issue type:
[X] question
Database system/driver:
[X]
postgres
TypeORM version:
[X]
0.2.7
I have these entities:
And I get the expected result when I execute this select:
Generated query and result:
But If I try to paginate it using skip and take:
This is the query and the error that I get:
The text was updated successfully, but these errors were encountered: