Arnar Birgisson wrote:
On 1/3/07, Michael Bayer <[EMAIL PROTECTED]> wrote: > yeah that would be why. SA's ORM has no ability to update primary key > columns from their original value....youll have to update it yourself, > or copy the object instance to a new one, etc. (or not make that col a > primary key) Ok thanks. Is there something fundamental in SA architecture that prevents updating of primary keys - or is it simply not implemented b/c it's complicated/difficult?
its something fundamental, i.e. the identity map: http://www.sqlalchemy.org/trac/wiki/FAQ#asingleobjectsprimarykeycanchangecanSAsORMhandleit adding code to update the column, and switch the identity of an entity, is not impossible. im not sure at this moment how involved it is, i have a feeling it will start out easy but then branch off into lots of unforseen ill effects that I cant predict at the moment. mostly, im just not sure if the ORM should really be taking on the task of changing the identity of entities in-session.
In any case, if SA can't update primary keys I'd expect it to blow up in my face if I tried doing that. Instead it just silently flushed the uow session without making any updates - leaving the model in inconsistent state with the database. Shouldn't there be some kind of error?
initially i hadnt made my mind up about that, since i dont want to get in the way of schemes that the user might be plotting, such as doing something in a MapperExtension.after_update() step. however i have a feeling that nobody is doing that sort of thing, so i can look into adding this check (ticket 412). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
