-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Take into account parent's primaryColumn config when fetching fr…
…om polymorphic child Before, on a child repository's options, we didn't handle the case in which there were multiple parents which had different `primaryColumn` names Now we take such configurations into account. Specifically, we fetch the metadata associated with the parent we are visiting and read its `primaryColumn`. This allows for multiple parents to have different ID names when such situations arise.
- Loading branch information
1 parent
a3d806d
commit 69cc478
Showing
4 changed files
with
71 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Entity, PrimaryGeneratedColumn } from 'typeorm'; | ||
import { PolymorphicChildren } from '../../../dist'; | ||
import { AdvertEntity } from './advert.entity'; | ||
|
||
@Entity('admins') | ||
export class AdminEntity { | ||
@PrimaryGeneratedColumn() | ||
admin_id: number; | ||
|
||
@PolymorphicChildren(() => AdvertEntity, { | ||
eager: false, | ||
primaryColumn: "admin_id" | ||
}) | ||
adverts: AdvertEntity[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters