#762 ✓resolved
Pat Maddox

auto_upgrade of inherited classes

Reported by Pat Maddox | January 10th, 2009 @ 07:33 PM

Resource subclasses aren't being added to the DataMapper::Resource.descendants set, so DataMapper.auto_migrate! and auto_upgrade! don't create properties defined in subclasses.

Comments and changes to this ticket

  • Pat Maddox

    Pat Maddox January 10th, 2009 @ 07:36 PM

    Here's a patch that adds the subclasses and thus gets the auto_migrator working (halfway?).

    There are at least two remaining edge cases that I'm aware of:

    auto_migrate only works on superclasses still. Calling DataMapper.auto_upgrade! creates properties from both the superclass and subclasses, but DataMapper.auto_upgrade! only creates properties from the superclasses

    custom inherited hooks need to call super. not sure what to do about that. a dm custom hook name (self.resource_inherited) would work but needs doco and is potentially error-prone.

  • Pat Maddox

    Pat Maddox January 10th, 2009 @ 07:42 PM

    Here's a failing spec for existing inherited hooks that do not call super.

    I suspect for the auto_upgrade! problem I'll have to look at the integration specs...I'm leaving for now though. Maybe someone else will magically make it all work while I'm away :)

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) February 21st, 2009 @ 01:10 AM

    • State changed from “unconfirmed” to “resolved”

    The specific issue of inherited classes not being tracked has been resolved in the dm-core/next branch.

    Only critical patches and security fixes are being made to the master branch, so this patch will not be applied, especially since this will be resolved in the next minor release.

    The new specs for auto-upgrade and auto-migrate have not been written yet as part of the re-spec/doc project, but I can confirm the attached script performs as expected.

    Incidentally I did find a small bug in Model#auto_upgrade! when writing the attached script (not specifically associated to this ticket) which has been committed and pushed.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket