Hi,
Thanks for your thoughts. Well, ok, maybe this behaviour isn't that bad, but i stil think Torque should handle this a bit differently, it at least could setNew(true) when i do modify my PKs or do something else so i could detect my error more easily... Anyway, i'm happy i know about this behaviour now, it could be documented somewhere at least.
Thomas Fischer wrote:
Hi,
I do not think this behaviour is as weird as it seems at fisrt thought. A primary key is there to identify an object uniquely, so if you change the primary key, you have a new object. Therefore, the update with the current values from the pk is ok for me. Usually this kind of problem pops up if your primary key also has a meaning in the real world. I have found it extremely helpful to use only primary keys which have no meaning in the real world except to identify the object uniquely; but this might not make sense in under all circumstances.
Suggestion how to change a primary key: start a transaction load the object call the peer class to delete the object by pk but keep a reference to the object in memory modify the primary key by the object's getters and setters call the setModified() and setNew() methods of your object both with argument true save the object (Torque will use a insert to do this because it thinks the object is new) commit the transaction.
Hope that helps,
Thomas
Marius Siegas <[EMAIL PROTECTED]> schrieb am 11.08.2004 17:51:44:
Hi,
I tried to modify my fields which are part of primary key and save object and it doesn't work. After some investigations i found out that Torque builds the WHERE clause from current values of the PK fields. Don't you think this behavior is ill? I try to modify one object and it turns out i will update another... On the other hand, what if i want to change the value of my primary key? Is it so uncommon?.. Torque could save objects PK when loading and then use it for saving object, why not?
-- Marius
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
