Skip to content

Commit 6a4b872

Browse files
committed
fix: pin 양방향 관계 설정, test에 반영 #255
1 parent cd4602e commit 6a4b872

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

backend/src/course/entity/CoursePlace.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class CoursePlace extends BaseEntity {
1515
@JoinColumn({ name: 'place_id' })
1616
place: Promise<Place>;
1717

18-
@ManyToOne(() => Course, {
18+
@ManyToOne(() => Course, (course) => course.pins, {
1919
onDelete: 'CASCADE',
2020
orphanedRowAction: 'delete',
2121
})

backend/src/map/MapRepository.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class MapRepository extends SoftDeleteRepository<Map, number> {
4545

4646
async findMapsWithPlace(page: number, pageSize: number) {
4747
return await this.createQueryBuilder('map')
48-
.leftJoinAndSelect('map.mapPlaces', 'mapPlace')
48+
.leftJoinAndSelect('map.pins', 'mapPlace')
4949
.leftJoinAndSelect('map.user', 'user')
5050
.where('map.isPublic = :isPublic', { isPublic: true })
5151
.andWhere('mapPlace.id IS NOT NULL')
@@ -57,7 +57,7 @@ export class MapRepository extends SoftDeleteRepository<Map, number> {
5757

5858
async countMapsWithPlace() {
5959
return await this.createQueryBuilder('map')
60-
.leftJoinAndSelect('map.mapPlaces', 'mapPlace')
60+
.leftJoinAndSelect('map.pins', 'mapPlace')
6161
.where('map.isPublic = :isPublic', { isPublic: true })
6262
.andWhere('mapPlace.id IS NOT NULL')
6363
.getCount();

backend/test/course/course.service.test.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ describe('CourseService', () => {
375375
),
376376
);
377377
const setPlacesOfCourseRequest = {
378-
places: places.map((place, index) => ({
378+
pins: places.map((place, index) => ({
379379
placeId: place.id,
380380
comment: `Comment ${index + 1}`,
381381
})),
@@ -386,11 +386,9 @@ describe('CourseService', () => {
386386
setPlacesOfCourseRequest,
387387
);
388388

389-
expect(result.places).toHaveLength(
390-
setPlacesOfCourseRequest.places.length,
391-
);
389+
expect(result.places).toHaveLength(setPlacesOfCourseRequest.pins.length);
392390

393-
setPlacesOfCourseRequest.places.forEach((expectedPlace, index) => {
391+
setPlacesOfCourseRequest.pins.forEach((expectedPlace, index) => {
394392
expect(result.places[index]).toMatchObject({
395393
id: expectedPlace.placeId,
396394
comment: expectedPlace.comment,

backend/test/map/map.repository.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ describe('MapRepository', () => {
171171
const expectedMaps = mapEntities.slice(5, 10).map((map) => {
172172
return {
173173
...map,
174-
mapPlaces: map.pins.map((place) => {
174+
pins: map.pins.map((place) => {
175175
return {
176176
color: place.color,
177177
createdAt: place.createdAt,

0 commit comments

Comments
 (0)