On Dec 11, 2013, at 12:45 PM, Iain Duncan <iainduncanli...@gmail.com> wrote:

> On Tue, Dec 10, 2013 at 3:54 PM, Michael Bayer <mike...@zzzcomputing.com> 
> wrote:
> 
> On Dec 10, 2013, at 5:04 PM, Iain Duncan <iainduncanli...@gmail.com> wrote:
> 
>> Hi, I'm stuck on how to do something that I'm sure must be possible.
>> 
>> I have two kinds of records, using table inheritance, Client, and 
>> SpecialClient. SpecialClient has extra fields and it's own polymorphic 
>> identity. I need to *promote* a and existing client record to a special 
>> client. I tried just making a SpecialClient and copying over attributes, but 
>> this is giving me "can't set attribute" error messages. Can anyone tell me 
>> what the *right* way to do change a polymorphic type, while keeping it's ID 
>> the same, would be? In my case, the ID in the derived type is an fkey to the 
>> base type table's id col.
> 
> if its joined inheritance, you have to INSERT into the new table manually, 
> that feature isn’t supported right now.   if it’s single, try emitting an 
> UPDATE for the “discriminator” column, then reloading the object.
> 
> 
> I think it's joined inheritance? The derived table's primarky key is an "id" 
> column that is also an fkey to the base table's "id" column and the  base 
> table has a "_type" column holding the poly id. Does this mean I should drop 
> into sql directly to create the record in the derived table and it will "just 
> work”?


you need to manipulate the tables directly, and then totally reload the 
original object fresh.  pretty much make the ORM think the previous Client 
never existed.


Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to