-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix(repository): allow model classes with recursive type references #3722
Conversation
2dcdb4a
to
14ac1ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
Some code change is probably not compatible with mongodb connector: https://travis-ci.com/strongloop/loopback-next/jobs/234512187 |
14ac1ee
to
bb2254f
Compare
Fixed. |
} | ||
|
||
// Create an internal legacy Model attached to the datasource | ||
private definePersistedModel( | ||
entityClass: typeof Model, | ||
visited: Map<typeof Model, typeof juggler.PersistedModel>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we leverage DataSource's ModelBuilder
instance that's already keeping track of models that have been defined, instead of creating a new map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not as ModelBuilder
has no idea of LB4 entity class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ModelBuilder
is keeping track of all models that are backing LB4 entity classes. Whenever we create a new Repository for an LB4 entity class, a new (Persisted)Model is registered with the ModelBuilder behind the datasource.
@bajtos PTAL |
I am not very happy about the current implementation, because it introduces multiple places that are keeping track of visited models ( Juggler already has means for handling circular references in models. I simplified your solution to leverage the concept of "unresolved models", now the fix consists of one new line added. @raymondfeng PTAL. If you agree with my proposed direction, then I am proposing the following next steps:
|
@bajtos Please approve loopbackio/loopback-datasource-juggler#1778 first. |
212876f
to
c6cb019
Compare
Fixes #3671 (comment) Co-authored-by: Miroslav Bajtoš <[email protected]>
c6cb019
to
ed6f243
Compare
Fixes #3671 (comment)
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated👉 Check out how to submit a PR 👈