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

Lazy relations in embedded entity broke Typeorm #3172

Open
dimensi opened this issue Nov 28, 2018 · 1 comment
Open

Lazy relations in embedded entity broke Typeorm #3172

dimensi opened this issue Nov 28, 2018 · 1 comment

Comments

@dimensi
Copy link

dimensi commented Nov 28, 2018

Issue type:

[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[x] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:
If i create lazy relations in embeded entity i got error
image
Repo example https://github.com/dimensi/typeorm-many-to-many-embeded-bug

https://github.com/dimensi/typeorm-many-to-many-embeded-bug/blob/90ba379d1a2e1d127365f5bd05a37a098dd18f61/src/entity/User.ts#L17-L20
If i remove promise, it will fix problem.

@queses
Copy link

queses commented Jun 6, 2019

Faced with this issue, it's still actual in 0.2.18

My temporary workaround is to define embedded entities in separate tables and to connect them with @OneToOne relation like that:

In parent entity:

@OneToOne(type => ChildEmbeddedEntity, rel => rel['parent'], { cascade: true })
private child: Promise<ChildEmbeddedEntity>

In child embedded entity:

@OneToOne(type => TestSpecialistAccount)
@JoinColumn()
private parent: ParentEntity

It works pretty OK, but adds an extra table which needs to be joined in queries.

I would be very happy to see a fix of the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants