diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-01-06 03:33:53 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-01-06 03:33:53 +0000 |
| commit | e1ceee15cd7e5692513ac83716b3201a47a0272e (patch) | |
| tree | 0caba521d22ed2042c1164a95661347bba0fb10f /lib/sqlalchemy | |
| parent | 672a69a45b22862ad1217830752d584fcd504f4d (diff) | |
| download | sqlalchemy-e1ceee15cd7e5692513ac83716b3201a47a0272e.tar.gz | |
- added an error message if you actually try to modify primary key values on an entity
and then flush it.
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 67ca75bb3..b6ff09616 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -841,7 +841,10 @@ class Mapper(object): if self.__should_log_debug: self.__log_debug("detected row switch for identity %s. will update %s, remove %s from transaction" % (instance_key, mapperutil.instance_str(obj), mapperutil.instance_str(existing))) uowtransaction.unregister_object(existing) - + if has_identity(obj): + if obj._instance_key != instance_key: + raise exceptions.FlushError("Can't change the identity of instance %s in session (existing identity: %s; new identity: %s)" % (mapperutil.instance_str(obj), obj._instance_key, instance_key)) + inserted_objects = util.Set() updated_objects = util.Set() |
