silverstripe / silverstripe-upgrader

A tool to help upgrade your code to handle API changes in packages you used.
BSD 3-Clause "New" or "Revised" License
40 stars 21 forks source link

Upgrader doesn't support relations that link to direct DB fields #168

Open madmatt opened 5 years ago

madmatt commented 5 years ago

Examples of old code to be upgraded:

class Account extends DataObject
{
    private static $has_one = [
        'Owner' => 'Member',
        'Parent' => 'Member',
    ];
}

class MemberExtension extends DataExtension
{
    private static $has_many = [
        'ParentAccounts' => 'Account.Parent',
        'OwnedAccounts' => 'Account.Owner',
    ];
}

Expected corrected code for SS4:

class Account extends DataObject
{
    private static $has_one = [
        'Owner' => Member::class,
        'Parent' => Member::class,
    ];
}

class MemberExtension extends DataExtension
{
    private static $has_many = [
        'ParentAccounts' => Account::class . '.Parent',
        'OwnedAccounts' => Account::class . '.Owner',
    ];
}

What actually happens: Changes to Account are made correctly, but MemberExtension does not change, presumably because the upgrader is only searching for exact class names in strings