avoid name collision in cross ref relations#1963
Merged
gechetspr merged 3 commits intopropelorm:masterfrom Nov 28, 2023
Merged
Conversation
Codecov ReportPatch coverage:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## master #1963 +/- ##
============================================
+ Coverage 88.56% 89.25% +0.69%
- Complexity 8051 8056 +5
============================================
Files 243 232 -11
Lines 24590 24552 -38
============================================
+ Hits 21777 21915 +138
+ Misses 2813 2637 -176
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 20 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
2e9e80f to
03ff801
Compare
olhalivitchuk
approved these changes
Nov 21, 2023
gechetspr
approved these changes
Nov 28, 2023
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #941
When you have three FKs on a cross-reference table, Propel will generate methods on the referenced tables, where the name uses a combination of the other two FKs. For example, if a cross-reference table has three FKs to the tables
A,BandC, Propel generates a methodclearABs()on tableC. The methods areclear*,init*,get*,set*,count*,doAdd*andremove*.This produces collisions when the name of the cross-reference table is a combination of the names of two of the referenced tables. In above example, that would happen when the cross-reference table is named
AB. (Somewhat unfortunately, this is the name suggested in the documentation.In this case, Propel adds some methods with the same name, once where it handles the cross-reference table (
clearABsto clear associated elements in the cross ref table), and once again where it handles the tables connected by the cross-reference table (clearABsto clear associated As and Bs). This leads to an exception.The name for the cross-ref relations is generated in
AbstractOmBuilder::getCrossFKsPhpNameAffix(), this change tests whether the current table has a FK relation to another table with the same name, and if so, prefixes the relation name withCross. The above method would then be calledclearCrossABs().From what I can see, this only affects names that could not occur before because of the error, so I don't think this affects BC.