[DBAL-361] [GH-213] fixed bug on schema comparator, prevent multiple rename candidates for a single original field Created: 04/Oct/12 Updated: 01/May/13 Resolved: 01/May/13 |
|
| Status: | Resolved |
| Project: | Doctrine DBAL |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 2.3.4 |
| Security Level: | All |
| Type: | Bug | Priority: | Major |
| Reporter: | Benjamin Eberlei | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This issue is created automatically through a Github pull request on behalf of leedavis81: Url: https://github.com/doctrine/dbal/pull/213 Message: Starting with the following Entity
Upon running diffTable($from, $to) in \Doctrine\DBAL\Schema\Comparator.php line 69 both new columns are added to the "addedColumns" array, and the one removed column is correctly present in the removedColumns array. The first iteration on detectColumnRenamings (line 272) puts the two NEW columns up as rename candidates as expected, however they share the original field name. When iterating over the rename candidates no further checks are done and these entries are added to the renamedColumns array. The last overwrites the original as they share the same array key and the original gets ignored. My change checks the renamedColumns array for the existence of the old column name. It only becomes a rename candidate if the original field hasn't already used previously. Otherwise it remains in the addedColumns array. In the example above these changes will produce 1 change column and 1 add column as expected. |
| Comments |
| Comment by Lee Davis [ 18/Apr/13 ] |
|
Is there anything else I need to do to get this to be merged? It's quite a frustrating issue that causes me to run an update twice to ensure changes to the DB have been correctly applied. This bug also affects the migrations tool. Pull request has been created https://github.com/doctrine/dbal/pull/213 |
| Comment by Doctrine Bot [ 01/May/13 ] |
|
A related Github Pull-Request [GH-213] was closed: |