-
-
Notifications
You must be signed in to change notification settings - Fork 495
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(query-builder): respect EntityManager
schema
#4849
Conversation
querybuilder will handle wildcard joined table in a predictable manner
Codecov ReportAll modified and coverable lines are covered by tests ✅
... and 8 files with indirect coverage changes 📢 Thoughts on this report? Let us know!. |
I am not entirely sure here, but I would prefer the less intrusive change. One thing that would be good to test more carefully is how this affects working with the
Not sure what you mean by that, like when you have a wildcard entity it would always prefer the EM schema (or the global one from config)? It already works like that, or not? I believe it's important to preserve that the (wildcard) owning entity schema is respected in the relations (if the relation target is also wildcard entity). |
I don't think
I added the same logic to ~167 and ~185. If undefined is treated the same it should check for that as well. There are more examples in the code where I will change to the less intrusive schema change. It will mean that if '*' is set as schema on the joined entity and I will add more tests for em.find to make sure it behaves the same. |
Added more test for em.find
tests/features/multiple-schemas-entity-manager/multiple-schemas-e-manager-q-builder.test.ts
Outdated
Show resolved
Hide resolved
tests/features/multiple-schemas-entity-manager/multiple-schemas-e-manager-q-builder.test.ts
Outdated
Show resolved
Hide resolved
tests/features/multiple-schemas-entity-manager/multiple-schemas-e-manager-q-builder.test.ts
Outdated
Show resolved
Hide resolved
As far as I can see This PR focuses on using the QueryBuilder directly and to make use of I would like to take a shoot at refactoring the usage of |
The current implementation is indeed pretty messy, I am having a hard time reasoning about the code... Do you plan to add something to this PR or can we merge? It looks good to me, and I'd like to ship new stable later today so would be good to include it there. |
I don't plan to add anything if you are happy. I will get back to you about schema prioritisation and use cases. All the best! |
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.
All right, thank you!
EntityManager
schema
Previously if you had an entity that belongs to schema n2 which have a FK to an entity that does not exist in n2 the query will fail since it will use
n2.SubDomain
. If you usedwithSchema('n5')
, then it will fail sincen5.Domain
does not exist.Im wondering what you think about this approach. One thing I'm a bit divided about is the fallback for
joinSchema
should it bev6 questions?
Should
schema: '*'
be treated the same way asschema: undefined
?I've kept the QueryBuilder.WithSchema logic that will make sure it will triumph all other schema settings. But I think it will be problematic to use, since it will not handle cases when entities are placed in different schemas.