Skip to content
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

feat(orm): @ManyToOne에서 외래키 생성 시, 기본키 탐색 방법 추가 #42

Closed
biud436 opened this issue Sep 19, 2024 · 1 comment

Comments

@biud436
Copy link
Owner

biud436 commented Sep 19, 2024

다음과 같은 구조의 연관 관계를 가진 엔티티가 있다고 할 때, order에는 외래키가 생성되어야 합니다.

/**
     * 상품 엔티티
     */
    @Entity()
    class Product {
        @PrimaryGeneratedColumn()
        id!: number;

        @Column({
            length: 255,
            nullable: false,
            type: "varchar",
        })
        name!: string;

        @Column({
            type: "int",
            nullable: false,
            length: 11,
            // default: 0,
        })
        price!: number;
    }

    @Entity()
    class Order {
        @PrimaryGeneratedColumn()
        id!: number;

        @Column({
            type: "int",
            nullable: false,
            length: 11,
            // name: "product_id", 면 생성이 되질 않음
        })
        productId!: number;

        @ManyToOne(() => Product, (product) => product.id, {
            joinColumn: "productId",
        })
        product!: Product;
    }

현재 연결할 키를 설정할 때, 옵션에서 joinColumn을 기입하여 찾고 있는데, 해당 옵션이 null 일 때에도 Product 테이블에서 기본키를 찾을 수 있어야 합니다.

@biud436 biud436 changed the title feat: 외래키 생성 시, 기본키 탐색 방법 추가 feat(orm): 외래키 생성 시, 기본키 탐색 방법 추가 Sep 19, 2024
@biud436 biud436 changed the title feat(orm): 외래키 생성 시, 기본키 탐색 방법 추가 feat(orm): @ManyToOne에서 외래키 생성 시, 기본키 탐색 방법 추가 Sep 19, 2024
@biud436 biud436 changed the title feat(orm): @ManyToOne에서 외래키 생성 시, 기본키 탐색 방법 추가 feat(orm): @ManyToOne에서 외래키 생성 시, 여러 기본키 탐색 방법 추가 Sep 19, 2024
@biud436 biud436 changed the title feat(orm): @ManyToOne에서 외래키 생성 시, 여러 기본키 탐색 방법 추가 feat(orm): @ManyToOne에서 외래키 생성 시, 기본키 탐색 방법 추가 Sep 19, 2024
@biud436
Copy link
Owner Author

biud436 commented Dec 17, 2024

#42, #44, #46, #47 은 결국 하나의 문제로 귀결됩니다. EntityManager.find를 호출하였을 때 제대로 역직렬화를 하는가? 입니다. 현재 내부 API는 완성되어있지만 관련된 메타데이터 체계를 어떻게 할 지 고민중입니다.

@biud436 biud436 closed this as completed Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant