On Dec 22, 2007, at 3:27 PM, andresj wrote:
> > I don't know if I'm too clear, but I'll try to explain it. I'm using a > set up similar to the one in > http://www.sqlalchemy.org/docs/04/mappers.html#advdatamapping_mapper_inheritance_joined > . I want to be able to change the type of an object. For example, in > the example in the link above, I want to be able to change an Employee > into an Engineer and viceversa. > > Is there a way to do this? Or should I delete the object and create a > new one? And in the last case (create new), how would I be able to > update ForeignKey relationships referencing the changed object? > we dont support this feature right now, its something we will implement eventually but its fairly complicated since we have to detect the condition, figure out additional tables which require INSERTs or DELETEs depending on the class change, etc. So for now, your best bet is to issue the SQL directly to the database for the particular class change you want to do, remove the objects in question from the session using expunge(), and reload as the new class. This would involve, for motion from a superclass to subclass INSERTing into the desired joined table, for motion from subclass to superclass DELETEing from the joined table, or for motion from one subclass to another INSERTing and DELETEing. For deeper inheritance, the above pattern becomes more complex. But I dont think "delete and create new" is necessary here - the "base" table can remain unchanged except for issuing an UPDATE to the "discriminator" column, assuming you have one. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---