You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m using TypeORM with NestJS and have encountered an issue when trying to use VirtualColumn with createQueryBuilder and paginate. The VirtualColumn fields are not recognized or included in the query results when using createQueryBuilder. Here is an example of my setup and the issue I’m facing:
Entity Definitions
@Entity('MonthlyBill')
@UseDto(MonthlyBillDto)exportclassMonthlyBillEntityextendsAbstractEntity<MonthlyBillDto>{
@Entity('Users')
@UseDto(UsersDto)exportclassUsersextendsAbstractEntity<UsersDto>{
@PrimaryGeneratedColumn()id: number;
@Column()group: string;
@VirtualColumn({query: (alias)=>`(SELECT COUNT(id) FROM Users WHERE group = ${alias}.group)`,})userCount: number;}
When using the above setup, the VirtualColumn fields userCount are not included in the query results. This issue occurs because createQueryBuilder does not recognize or include VirtualColumn fields in the results.
Request
Is there a recommended approach to use VirtualColumn with createQueryBuilder and paginate in TypeORM? If not, could support for this feature be added? It would be very helpful to be able to use VirtualColumn seamlessly with createQueryBuilder and pagination.
Thank you for your assistance.
The text was updated successfully, but these errors were encountered:
I’m using TypeORM with NestJS and have encountered an issue when trying to use VirtualColumn with createQueryBuilder and paginate. The VirtualColumn fields are not recognized or included in the query results when using createQueryBuilder. Here is an example of my setup and the issue I’m facing:
Entity Definitions
Query Builder and Pagination
Issue
When using the above setup, the VirtualColumn fields userCount are not included in the query results. This issue occurs because createQueryBuilder does not recognize or include VirtualColumn fields in the results.
Request
Is there a recommended approach to use VirtualColumn with createQueryBuilder and paginate in TypeORM? If not, could support for this feature be added? It would be very helpful to be able to use VirtualColumn seamlessly with createQueryBuilder and pagination.
Thank you for your assistance.
The text was updated successfully, but these errors were encountered: