leftJoinAndMapMany is not mapping the result to the property when I pass a Subquery to the second argument
See original GitHub issueIssue type: [X] bug
Database system/driver:
[X] postgres
TypeORM version:
[X] latest
Steps to reproduce:
- Clone this repo
npm install && tscnpm start
These are the entities:
@Entity()
export class Category {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
posts: Post[];
}
@Entity()
export class Post {
@PrimaryGeneratedColumn()
id: number;
@Column()
title: string;
@Column('int')
categoryId: number;
}
And this is how I build the queries:
This one returns the list of Posts:
connection.createQueryBuilder().select('category').from(Category, 'category')
.leftJoinAndMapMany('category.posts', Post, 'post', 'post.categoryId = category.id');
This one does not:
connection.createQueryBuilder().select('category').from(Category, 'category')
.leftJoinAndMapMany('category.posts', qb => qb.select().from(Post, 'post'), 'post', 'post."categoryId" = category.id');
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (3 by maintainers)
Top Results From Across the Web
leftJoinAndMapMany is not mapping the result to the property ...
leftJoinAndMapMany is not mapping the result to the property when I pass a Subquery to the second argument ; Issue type: [X] bug...
Read more >TypeORM - Query Builder with Subquery - DEV Community
Building a simple SELECT query with entities is easy. However, this is not enough for creating graphs or displaying calculated results on the ......
Read more >SelectQueryBuilder | typeorm
It will assume that there is a single row of selecting data, and mapped result will be a single selected value. Given entity...
Read more >Is it possible to use subquery in leftJoinAndSelect in TypeORM
Using the SubQueryFactory option does not automatically create the on clause as the condition as it cannot know what the underlying query's ...
Read more >https://unpkg.com/typeorm@0.2.7/query-builder/Sele...
subQuery (): SelectQueryBuilder<any>; /** * Creates SELECT query. ... that there are multiple rows of selecting data, and mapped result will be an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m going to deprecate joinAndMap methods in 0.4.0 and don’t recommend to use them. Alternative is to execute a separate query, if you need to have it in the same query consider using raw query.
Is there any solution?