avoid name collision in cross ref relations #1963
Merged
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
,B
andC
, 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 (
clearABs
to clear associated elements in the cross ref table), and once again where it handles the tables connected by the cross-reference table (clearABs
to 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.