-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
Description
Issue Description
Coming from #1882. Running a query builder in leftJoinAndMapOne doesn't map to property.
Expected Behavior
leftJoinAndMapOne should map to the provided property.
Actual Behavior
I am trying to do something like
const [venues, venuesCount] = this.venuesRepository
.createQueryBuilder("Venue")
.leftJoinAndSelect("Venue.city", "city")
.leftJoinAndMapOne(
"Venue.eventStats",
(qb) =>
qb
.from("events", "Event")
.select('"venueId"')
.addSelect(`MAX("capacity")`, "maxVenueCapacity")
.addSelect(`COUNT("venueId")`, "eventsCount")
.groupBy('"venueId"'),
"Event",
"Venue.id = Event.venueId"
)
.where(`Venue.cityId = :cityId`, { cityId: "someCityId" })
.orderBy(`eventCount`, `DESC`)
.getManyAndCount();And my model has
interface EventStats {
maxVenueCapacity: number;
eventsCount: number;
}
@Entity()
class Venue {
eventStats: EventStats;
}at the end venues[].eventStats is not added.
// include the output in code tags like these!
Steps to Reproduce
- Use the code I provided above to create a similar query.
- Run the query and check if the mapped property is getting added.
My Environment
| Dependency | Version |
|---|---|
| Operating System | Docker Node Alpine Image |
| Node.js version | 14.17.0 |
| Typescript version | 4.5.4 |
| TypeORM version | 0.2.41 |
Additional Context
Relevant Database Driver(s)
| DB Type | Reproducible |
|---|---|
postgres |
yes |
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
jmcelreavey