Fix collision of class names between namespaces#1313
Fix collision of class names between namespaces#1313Almamu wants to merge 1 commit intopropelorm:masterfrom
Conversation
Fixes an use case like this one:
<database name="default" defaultIdMethod="native" defaultPhpNamingMethod="underscore" namespace="Database">
<table name="arclabs_accounts" idMethod="native" phpName="Account" namespace="ArcLaboratories">
[...]
</table>
<table name="mlabs_accounts" idMethod="native" phpName="Account" namespace="MinecraftLaboratories">
[...]
</table>
</database>
| $autoAliasName = 'Child' . $class; | ||
| // $autoAliasName = 'Child' . $class; | ||
| // FIXME: USE A DIFFERENT SYSTEM TO GENERATE AN UNIQUE NAME FOR THIS CLASS? | ||
| $autoAliasName = $class . md5($namespace); |
There was a problem hiding this comment.
Oh, well, no md5 in names please :P
There was a problem hiding this comment.
That just change the aliases generated for class names (for the use in autogenerated classes, doesnt change any class name) I do agree that MD5 is not the best way, but there are not many ways of doing it. At first I though to generate a name based on the namespace and that could probably be better... for example, get the last namespace and concat it to the class name so a case like the one on the PR generates valid use statements that do not collide. That would generate aliases like MinecraftLaboratoriesAccount and ArcLaboratoriesAccount in case of a collision in the class name, but that could lead to more complex databases to have collisions too (for multiple namespaces or long namespaces, hence md5 does better job in those weird cases, but they are still weird cases anyway...). Would that be a better approach then?
|
Fixes an use case like this one: