-
-
Notifications
You must be signed in to change notification settings - Fork 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(core): self-referencing relations Not unique table/alias
#2740
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4034445
fix(core): self-referencing relations `Not unique table/alias`
monrostar 10c0798
fix(core): update self-related manual joins with deep eager relations
monrostar 4824d86
chore(core): clean up code
monrostar 5eb6391
fix(core): update test cases for new TestEntities order
monrostar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -696,7 +696,17 @@ export class ListQueryBuilder implements OnApplicationBootstrap { | |
currentAlias: string, | ||
) => { | ||
const currentMetadataIsTreeType = metadata.treeType; | ||
if (!currentParentIsTreeType && !currentMetadataIsTreeType) { | ||
let currentMetadataHasOneOrMoreSelfReferencingRelations = false; | ||
// Check if the current entity has one or more self-referencing relations | ||
// to determine if it is a tree type or has tree relations. | ||
for (const relation of currentMetadata.relations) { | ||
if (relation.inverseEntityMetadata === currentMetadata) { | ||
currentMetadataHasOneOrMoreSelfReferencingRelations = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!currentParentIsTreeType && !currentMetadataIsTreeType && !currentMetadataHasOneOrMoreSelfReferencingRelations) { | ||
return; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the most important code. It is enough to determine whether it is necessary to do join manually or leave this job to typeorm |
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Here I had to update the model a bit to repeat the error and take it into account in the tests
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.
above fix i think need consider more behavior
if we have
translations
likethe
parent
should be auto loadtranslations
otherwise it will resulttranslateEntity
failedif
parent
existed but it have auto loadedtranslations
it will broken hereThere 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.
please see my latest updated repo https://github.com/tianyingchun/next-issue/tree/vendure_issue_2738
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.
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.
Interesting. I thought I had accounted for translations for all self-related relations. I will look into this and add join for eager relations